Class: OpenStax::Aws::SecretsSubstitutionsFactory

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ SecretsSubstitutionsFactory

Returns a new instance of SecretsSubstitutionsFactory.

Raises:

  • (ArgumentError)


115
116
117
118
119
# File 'lib/openstax/aws/secrets_factory.rb', line 115

def initialize(context)
  raise ArgumentError, "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



121
122
123
124
125
# File 'lib/openstax/aws/secrets_factory.rb', line 121

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



113
114
115
# File 'lib/openstax/aws/secrets_factory.rb', line 113

def attributes
  @attributes
end