Class: Katello::ProductContentFinder
- Inherits:
-
Object
- Object
- Katello::ProductContentFinder
- Defined in:
- app/services/katello/product_content_finder.rb
Instance Attribute Summary collapse
-
#consumable ⇒ Object
Returns the value of attribute consumable.
-
#match_environment ⇒ Object
Returns the value of attribute match_environment.
-
#match_subscription ⇒ Object
Returns the value of attribute match_subscription.
Class Method Summary collapse
Instance Method Summary collapse
- #custom_content_labels ⇒ Object
-
#initialize(params = {}) ⇒ ProductContentFinder
constructor
consumable must implement: content_view_environments organization products.
- #presenter_with_overrides(overrides) ⇒ Object
- #product_content ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ ProductContentFinder
consumable must implement:
content_view_environments
organization
products
9 10 11 12 13 14 |
# File 'app/services/katello/product_content_finder.rb', line 9 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 |
Instance Attribute Details
#consumable ⇒ Object
Returns the value of attribute consumable.
3 4 5 |
# File 'app/services/katello/product_content_finder.rb', line 3 def consumable @consumable end |
#match_environment ⇒ Object
Returns the value of attribute match_environment.
3 4 5 |
# File 'app/services/katello/product_content_finder.rb', line 3 def match_environment @match_environment end |
#match_subscription ⇒ Object
Returns the value of attribute match_subscription.
3 4 5 |
# File 'app/services/katello/product_content_finder.rb', line 3 def match_subscription @match_subscription end |
Class Method Details
.wrap_with_overrides(product_contents:, overrides:, status: nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/services/katello/product_content_finder.rb', line 40 def self.wrap_with_overrides(product_contents:, overrides:, status: nil) pc_with_overrides = product_contents.map { |pc| ProductContentPresenter.new(pc, overrides) } if status pc_with_overrides.keep_if do |pc| if status == "overridden" pc.status[:overridden] else pc.status[:status] == status end end end pc_with_overrides end |
Instance Method Details
#custom_content_labels ⇒ Object
36 37 38 |
# File 'app/services/katello/product_content_finder.rb', line 36 def custom_content_labels product_content.custom.map { |pc| pc.product.root_repositories.map(&:custom_content_label) }.flatten.uniq end |
#presenter_with_overrides(overrides) ⇒ Object
54 55 56 |
# File 'app/services/katello/product_content_finder.rb', line 54 def presenter_with_overrides(overrides) product_content.map { |pc| ProductContentPresenter.new(pc, overrides) } end |
#product_content ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/katello/product_content_finder.rb', line 16 def product_content if match_environment if consumable.is_a?(::Katello::ActivationKey) # TODO: remove this when AKs are refactored for multi CV environment = consumable.lifecycle_environment view = consumable.content_view return ProductContent.none unless environment && view versions = ContentViewVersion.in_environment(environment).where(:content_view_id => view).first else # consumable is a SubscriptionFacet versions = consumable.content_view_environments.select(:content_view_version_id).map(&:content_view_version_id) end 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(versions) if versions.present? consumable.organization.enabled_product_content_for(roots) end |