Class: OpenStax::Aws::StackFactory::VolatileParametersFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/openstax/aws/stack_factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ VolatileParametersFactory

Returns a new instance of VolatileParametersFactory.



143
144
145
146
147
# File 'lib/openstax/aws/stack_factory.rb', line 143

def initialize(context)
  raise "context cannot be nil" if context.nil?
  @context = context
  @attributes = {}
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



149
150
151
152
153
# File 'lib/openstax/aws/stack_factory.rb', line 149

def method_missing(name, *args, &block)
  raise "Volatile parameter `#{name}` cannot be called with arguments, only a block" if !args.empty?
  raise "Volatile parameter `#{name}` must be called with a block to set the parameter value" if !block_given?
  attributes[name.to_sym] = @context.instance_eval(&block)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



141
142
143
# File 'lib/openstax/aws/stack_factory.rb', line 141

def attributes
  @attributes
end