Class: Katello::Candlepin::ProductContent
- Inherits:
-
Object
- Object
- Katello::Candlepin::ProductContent
- Includes:
- ForemanTasks::Triggers
- Defined in:
- app/models/katello/candlepin/product_content.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
Returns the value of attribute content.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#product ⇒ Object
Returns the value of attribute product.
Instance Method Summary collapse
- #content_override(activation_key) ⇒ Object
- #content_type ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #displayable? ⇒ Boolean
-
#initialize(params = {}, product_id = nil) ⇒ ProductContent
constructor
A new instance of ProductContent.
- #repositories ⇒ Object
Constructor Details
#initialize(params = {}, product_id = nil) ⇒ ProductContent
Returns a new instance of ProductContent.
7 8 9 10 11 12 13 14 |
# File 'app/models/katello/candlepin/product_content.rb', line 7 def initialize(params = {}, product_id = nil) params = params.with_indifferent_access #controls whether repo is enabled in yum repo file on client # unrelated to enable/disable from katello @enabled = params[:enabled] @content = Candlepin::Content.new(params[:content]) @product_id = product_id end |
Instance Attribute Details
#content ⇒ Object
Returns the value of attribute content.
5 6 7 |
# File 'app/models/katello/candlepin/product_content.rb', line 5 def content @content end |
#enabled ⇒ Object
Returns the value of attribute enabled.
5 6 7 |
# File 'app/models/katello/candlepin/product_content.rb', line 5 def enabled @enabled end |
#product ⇒ Object
Returns the value of attribute product.
5 6 7 |
# File 'app/models/katello/candlepin/product_content.rb', line 5 def product @product end |
Instance Method Details
#content_override(activation_key) ⇒ Object
33 34 35 36 |
# File 'app/models/katello/candlepin/product_content.rb', line 33 def content_override(activation_key) override = activation_key.content_overrides.find { |pc| pc[:contentLabel] == content.label } override.nil? ? 'default' : override[:value] end |
#content_type ⇒ Object
38 39 40 |
# File 'app/models/katello/candlepin/product_content.rb', line 38 def content_type self.content.type end |
#create ⇒ Object
16 17 18 |
# File 'app/models/katello/candlepin/product_content.rb', line 16 def create @content.create end |
#destroy ⇒ Object
20 21 22 |
# File 'app/models/katello/candlepin/product_content.rb', line 20 def destroy @content.destroy end |
#displayable? ⇒ Boolean
42 43 44 45 46 47 48 49 50 51 |
# File 'app/models/katello/candlepin/product_content.rb', line 42 def displayable? case content_type when ::Katello::Repository::CANDLEPIN_DOCKER_TYPE false when ::Katello::Repository::CANDLEPIN_OSTREE_TYPE ::Katello::RepositoryTypeManager.enabled?(Repository::OSTREE_TYPE) else true end end |
#repositories ⇒ Object
29 30 31 |
# File 'app/models/katello/candlepin/product_content.rb', line 29 def repositories @repos ||= self.product.repos(self.product.organization.library).where(:content_id => self.content.id) end |