Class: Workarea::Search::ProductEntries
- Inherits:
-
Object
- Object
- Workarea::Search::ProductEntries
- 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
- #entries ⇒ Object
- #index_entries_for(product) ⇒ Object
-
#initialize(products) ⇒ ProductEntries
constructor
A new instance of ProductEntries.
- #live_entries ⇒ Object
- #release_entries ⇒ Object
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
#entries ⇒ Object
15 16 17 |
# File 'app/queries/workarea/search/product_entries.rb', line 15 def entries @entries ||= live_entries + release_entries end |
#index_entries_for(product) ⇒ Object
33 34 35 |
# File 'app/queries/workarea/search/product_entries.rb', line 33 def index_entries_for(product) Search::Storefront::Product.new(product) end |
#live_entries ⇒ Object
19 20 21 22 23 |
# File 'app/queries/workarea/search/product_entries.rb', line 19 def live_entries @live_entries ||= @products.flat_map do |product| index_entries_for(product.without_release) end end |
#release_entries ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/queries/workarea/search/product_entries.rb', line 25 def release_entries @release_entries ||= @products.flat_map do |product| ProductReleases.new(product).releases.map do |release| index_entries_for(product.in_release(release)) end end end |