Class: Mixlib::Install::ProductMatrix
- Inherits:
-
Object
- Object
- Mixlib::Install::ProductMatrix
- Defined in:
- lib/mixlib/install/product.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ ProductMatrix
constructor
A new instance of ProductMatrix.
-
#lookup(key, version = :latest) ⇒ Product
Looks up a product and sets version on it to be used later by the Product.
-
#product(key, &block) ⇒ Object
The only DSL method of this class.
-
#products ⇒ Object
Fetches the keys of available products.
Constructor Details
#initialize(&block) ⇒ ProductMatrix
Returns a new instance of ProductMatrix.
121 122 123 124 |
# File 'lib/mixlib/install/product.rb', line 121 def initialize(&block) @product_map = {} instance_eval(&block) end |
Instance Method Details
#lookup(key, version = :latest) ⇒ Product
Looks up a product and sets version on it to be used later by the Product.
152 153 154 155 156 157 158 159 160 |
# File 'lib/mixlib/install/product.rb', line 152 def lookup(key, version = :latest) product = @product_map[key] # We set the lookup version for the product to a very high number in # order to mimic :latest so that one does not need to handle this # symbol explicitly when constructing logic based on version numbers. version = "1000.1000.1000" if version.to_sym == :latest product.version(version) product end |
#product(key, &block) ⇒ Object
The only DSL method of this class. It creates a Product with given ‘key` and stores it.
130 131 132 |
# File 'lib/mixlib/install/product.rb', line 130 def product(key, &block) @product_map[key] = Product.new(&block) end |
#products ⇒ Object
Fetches the keys of available products.
138 139 140 |
# File 'lib/mixlib/install/product.rb', line 138 def products @product_map.keys end |