Class: Katello::Pulp3::ContentViewVersion::ImportableProducts
- Inherits:
-
Object
- Object
- Katello::Pulp3::ContentViewVersion::ImportableProducts
- Defined in:
- app/services/katello/pulp3/content_view_version/importable_products.rb
Instance Attribute Summary collapse
-
#creatable ⇒ Object
readonly
Returns the value of attribute creatable.
-
#updatable ⇒ Object
readonly
Returns the value of attribute updatable.
Instance Method Summary collapse
- #generate! ⇒ Object
-
#initialize(organization:, metadata_products:) ⇒ ImportableProducts
constructor
A new instance of ImportableProducts.
Constructor Details
#initialize(organization:, metadata_products:) ⇒ ImportableProducts
Returns a new instance of ImportableProducts.
7 8 9 10 11 12 13 |
# File 'app/services/katello/pulp3/content_view_version/importable_products.rb', line 7 def initialize(organization:, metadata_products:) @organization = organization @metadata_products = @creatable = [] @updatable = [] @products_in_library = ::Katello::Product.in_org(@organization).custom end |
Instance Attribute Details
#creatable ⇒ Object (readonly)
Returns the value of attribute creatable.
5 6 7 |
# File 'app/services/katello/pulp3/content_view_version/importable_products.rb', line 5 def creatable @creatable end |
#updatable ⇒ Object (readonly)
Returns the value of attribute updatable.
5 6 7 |
# File 'app/services/katello/pulp3/content_view_version/importable_products.rb', line 5 def updatable @updatable end |
Instance Method Details
#generate! ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/katello/pulp3/content_view_version/importable_products.rb', line 15 def generate! # This returns a 2 different list of importable products # creatable: products that are part of the metadata but not in the library. # They are ready to be created # updatable: products that are both in the metadata and library. # These may contain updates to the product and hence ready to be updated. @metadata_products.each do |product| next if product.redhat library_product = @products_in_library.find { |p| p.label == product.label } if library_product # add to the update list if product is already available updatable << { product: library_product, options: update_params(product) } else # add to the create list if its a new product creatable << { product: ::Katello::Product.new(create_params(product)) } end end end |