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 ||= 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_entriesObject



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_entriesObject



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