Class: Mixlib::Install::ProductMatrix

Inherits:
Object
  • Object
show all
Defined in:
lib/mixlib/install/product.rb

Instance Method Summary collapse

Constructor Details

#initialize(&block) ⇒ ProductMatrix

Returns a new instance of ProductMatrix.



125
126
127
128
# File 'lib/mixlib/install/product.rb', line 125

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.

Parameters:

  • key (String)

    Lookup key of the product.

  • version (String) (defaults to: :latest)

    Version to be set for the product. By default version is set to :latest

Returns:



156
157
158
159
160
161
162
163
164
# File 'lib/mixlib/install/product.rb', line 156

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.



134
135
136
# File 'lib/mixlib/install/product.rb', line 134

def product(key, &block)
  @product_map[key] = Product.new(&block)
end

#productsObject

Fetches the keys of available products.



142
143
144
# File 'lib/mixlib/install/product.rb', line 142

def products
  @product_map.keys
end