Class: Katello::Candlepin::ProductContent

Inherits:
Object
  • Object
show all
Includes:
ForemanTasks::Triggers
Defined in:
app/models/katello/candlepin/product_content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#contentObject

Returns the value of attribute content.



5
6
7
# File 'app/models/katello/candlepin/product_content.rb', line 5

def content
  @content
end

#enabledObject

Returns the value of attribute enabled.



5
6
7
# File 'app/models/katello/candlepin/product_content.rb', line 5

def enabled
  @enabled
end

#productObject

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_typeObject



38
39
40
# File 'app/models/katello/candlepin/product_content.rb', line 38

def content_type
  self.content.type
end

#createObject



16
17
18
# File 'app/models/katello/candlepin/product_content.rb', line 16

def create
  @content.create
end

#destroyObject



20
21
22
# File 'app/models/katello/candlepin/product_content.rb', line 20

def destroy
  @content.destroy
end

#displayable?Boolean

Returns:

  • (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

#repositoriesObject



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