Class: QuickSearch::AddressPresenter
- Inherits:
-
PinPresenter
- Object
- PinPresenter
- QuickSearch::AddressPresenter
- Defined in:
- app/presenters/quick_search/address_presenter.rb
Overview
Presents an Address as a quick search result / pinned item, resolving the
card to the address's party or first shipping order.
Instance Method Summary collapse
-
#profile_image_url ⇒ String?
The party's 80x80 profile image URL, or nil.
-
#set_attributes ⇒ void
Sets the card title, sub-header, link, and reference number from the address's party or first shipping order; marks the pin invalid when the address belongs to neither.
Instance Method Details
#profile_image_url ⇒ String?
Returns the party's 80x80 profile image URL, or nil.
32 33 34 35 36 |
# File 'app/presenters/quick_search/address_presenter.rb', line 32 def profile_image_url return if result.party&.profile_image.blank? result.party.profile_image.image_url(width: 80, height: 80) end |
#set_attributes ⇒ void
This method returns an undefined value.
Sets the card title, sub-header, link, and reference number from the
address's party or first shipping order; marks the pin invalid when the
address belongs to neither.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/presenters/quick_search/address_presenter.rb', line 13 def set_attributes if result.party&.try(:reference_number) @title = result.party.full_name @sub_header = formatted_sub_header @link = polymorphic_path(result.party) @reference_number = result.party.reference_number set_result_class(result.party) elsif (order = result.shipping_orders.first) @title = "Order #{order.reference_number}" @sub_header = formatted_sub_header @link = order_path(order) @reference_number = order.reference_number set_result_class(order) else @invalid = true end end |