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)


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

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



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

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.



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

def attributes
  @attributes
end