Class: Workarea::Search::ProductEntries

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
app/queries/workarea/search/product_entries.rb

Overview

This class exists to provide plugins and host applications a single point of modification for changing the logic around indexing products See workarea-browse_option or workarea-package_products for example.

Instance Method Summary collapse

Constructor Details

#initialize(products) ⇒ ProductEntries

Returns a new instance of ProductEntries.



11
12
13
# File 'app/queries/workarea/search/product_entries.rb', line 11

def initialize(products)
  @products = Array.wrap(products)
end

Instance Method Details

#entriesObject



15
16
17
# File 'app/queries/workarea/search/product_entries.rb', line 15

def entries
  @entries ||= @products.flat_map { |p| index_entries_for(p) }
end

#index_entries_for(product) ⇒ Object



19
20
21
# File 'app/queries/workarea/search/product_entries.rb', line 19

def index_entries_for(product)
  Search::Storefront::Product.new(product)
end