Class: Katello::InstalledProduct

Inherits:
Model
  • Object
show all
Defined in:
app/models/katello/installed_product.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#destroy!

Class Method Details

.find_or_create_from_consumer(consumer_attributes) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/katello/installed_product.rb', line 9

def self.find_or_create_from_consumer(consumer_attributes)
  attributes = {
    :arch => consumer_attributes['arch'],
    :version => consumer_attributes['version'],
    :name => consumer_attributes['productName'],
    :cp_product_id => consumer_attributes['productId']
  }
  Katello::Util::Support.active_record_retry do
    unless self.where(attributes).exists?
      self.create!(attributes)
    end
  end
  self.where(attributes).first
end

Instance Method Details

#consumer_attributesObject



24
25
26
27
28
29
30
31
# File 'app/models/katello/installed_product.rb', line 24

def consumer_attributes
  {
    :arch => arch,
    :version => version,
    :productName => name,
    :productId => cp_product_id
  }
end