Class: QuickSearch::ItemPresenter

Inherits:
PinPresenter
  • Object
show all
Defined in:
app/presenters/quick_search/item_presenter.rb

Overview

Presents an Item as a quick search result / pinned item, with state and
ASIN badges; publication items link to the publication page instead.

See Also:

Instance Method Summary collapse

Instance Method Details

#set_attributesvoid

This method returns an undefined value.

Sets the card title (SKU), badge sub-header, link, and result class.



11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/presenters/quick_search/item_presenter.rb', line 11

def set_attributes
  @title = result.sku
  @sub_header = +''
  @sub_header << item_state_badge
  @sub_header << h.tag.span(result.amazon_asin, class: 'badge bg-info') if result.amazon_asin.present?
  if result.is_publication?
    @link = publication_path(result)
    @result_class = :publication
  else
    @link = item_path(result)
    @result_class = :item
  end
end

#text_sub_headerString

Returns the item name shown as plain-text sub-header.

Returns:

  • (String)

    the item name shown as plain-text sub-header



26
27
28
# File 'app/presenters/quick_search/item_presenter.rb', line 26

def text_sub_header
  result.name
end