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
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
35 36 37 |
# File 'app/queries/workarea/search/product_entries.rb', line 35 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.reduce([]) do |memo, product| memo + Array.wrap(index_entries_for(product.without_release)) end end |
#release_entries ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'app/queries/workarea/search/product_entries.rb', line 25 def release_entries @release_entries ||= @products.reduce([]) do |results, product| releases = ProductReleases.new(product).releases results + releases.reduce([]) do |memo, release| memo + Array.wrap(index_entries_for(product.in_release(release))) end end end |