Sha256: 787b848e27f1aff88fdad7da5d94c90d45e35ee467c30958e32c6dc48598ca10

Contents?: true

Size: 1.2 KB

Versions: 91

Compression:

Stored size: 1.2 KB

Contents

module Katello
  class ProductContentFinder
    attr_accessor :match_environment, :match_subscription, :consumable

    #consumable must implement:
    #  content_view
    #  lifecycle_environment
    #  organization
    #  products
    def initialize(params = {})
      self.match_subscription = false
      self.match_environment = false

      params.each_pair { |k, v| instance_variable_set("@#{k}", v) unless v.nil? }
    end

    def product_content
      if match_environment
        environment = consumable.lifecycle_environment
        view = consumable.content_view
        return [] unless environment && view
        version = ContentViewVersion.in_environment(environment).where(:content_view_id => view).first
      end

      considered_products = match_subscription ? consumable.products : consumable.organization.products.enabled.uniq

      roots = Katello::RootRepository.where(:product_id => considered_products).subscribable
      roots = roots.in_content_view_version(version) if version

      consumable.organization.enabled_product_content_for(roots)
    end

    def presenter_with_overrides(overrides)
      product_content.map { |pc| ProductContentPresenter.new(pc, overrides) }
    end
  end
end

Version data entries

91 entries across 91 versions & 1 rubygems

Version Path
katello-4.0.3 app/services/katello/product_content_finder.rb
katello-3.18.5 app/services/katello/product_content_finder.rb
katello-4.0.2.1 app/services/katello/product_content_finder.rb
katello-4.0.2 app/services/katello/product_content_finder.rb
katello-3.18.4 app/services/katello/product_content_finder.rb
katello-4.0.1.2 app/services/katello/product_content_finder.rb
katello-3.18.3.1 app/services/katello/product_content_finder.rb
katello-4.0.1.1 app/services/katello/product_content_finder.rb
katello-3.18.3 app/services/katello/product_content_finder.rb
katello-4.0.1 app/services/katello/product_content_finder.rb
katello-4.0.0 app/services/katello/product_content_finder.rb
katello-4.0.0.rc3.1 app/services/katello/product_content_finder.rb
katello-4.0.0.rc3 app/services/katello/product_content_finder.rb
katello-3.18.2.1 app/services/katello/product_content_finder.rb
katello-3.18.2 app/services/katello/product_content_finder.rb
katello-3.17.3 app/services/katello/product_content_finder.rb
katello-4.0.0.rc2 app/services/katello/product_content_finder.rb
katello-3.18.1.1 app/services/katello/product_content_finder.rb
katello-3.17.2 app/services/katello/product_content_finder.rb
katello-4.0.0.rc1 app/services/katello/product_content_finder.rb