class Moonshot::ParameterCollection

A Rigid Hash-like structure that only accepts manipulation of parameters defined in the Stack template. Anything else results in an exception.

Public Class Methods

from_template(template) click to toggle source
# File lib/moonshot/parameter_collection.rb, line 10
def self.from_template(template)
  obj = new

  template.parameters.each do |stack_parameter|
    obj.add(stack_parameter)
  end

  obj
end
new() click to toggle source
# File lib/moonshot/parameter_collection.rb, line 20
def initialize
  @hash = {}
end

Public Instance Methods

[]=(key, value) click to toggle source
# File lib/moonshot/parameter_collection.rb, line 24
def []=(key, value)
  raise "Invalid StackParameter #{key}!" unless @hash.key?(key)

  @hash[key].set(value)
end
add(parameter) click to toggle source
# File lib/moonshot/parameter_collection.rb, line 30
def add(parameter)
  raise ArgumentError, 'Can only add StackParameters!' unless parameter.is_a?(StackParameter)

  @hash[parameter.name] = parameter
end
missing_for_create() click to toggle source

What parameters are missing for a CreateStack call, where UsePreviousValue has no meaning.

# File lib/moonshot/parameter_collection.rb, line 38
def missing_for_create
  # If we haven't set a value, and there is no default, we can't
  # create the stack.
  @hash.values.select { |v| !v.set? && !v.default? }
end
missing_for_update() click to toggle source
# File lib/moonshot/parameter_collection.rb, line 44
def missing_for_update
  # If we don't have a previous value to use, we haven't set a
  # value, and there is no default, we can't update a stack.
  @hash.values.select { |v| !v.set? && !v.default? && !v.use_previous? }
end