Sha256: 01017b0b0b17986f6cfb43004314c8b423e8a18b6948bb2001f8d3058068185b

Contents?: true

Size: 1.03 KB

Versions: 10

Compression:

Stored size: 1.03 KB

Contents

module Workarea
  module Search
    # 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.
    #
    class ProductEntries
      include Enumerable
      delegate :any?, :empty?, :each, :size, to: :entries

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

      def entries
        @entries ||= live_entries + release_entries
      end

      def live_entries
        @live_entries ||= @products.flat_map do |product|
          index_entries_for(product.without_release)
        end
      end

      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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
workarea-core-3.5.8 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.7 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.6 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.5 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.4 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.3 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.2 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.1 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.0 app/queries/workarea/search/product_entries.rb
workarea-core-3.5.0.beta.1 app/queries/workarea/search/product_entries.rb