Class: OpenStax::Aws::SecretsSpecificationFactory

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) ⇒ SecretsSpecificationFactory

Returns a new instance of SecretsSpecificationFactory.

Raises:

  • (ArgumentError)


90
91
92
93
94
# File 'lib/openstax/aws/secrets_factory.rb', line 90

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



100
101
102
# File 'lib/openstax/aws/secrets_factory.rb', line 100

def method_missing(name, *args, &block)
  store_attribute(name, *args, &block)
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



88
89
90
# File 'lib/openstax/aws/secrets_factory.rb', line 88

def attributes
  @attributes
end

Instance Method Details

#format(&block) ⇒ Object



96
97
98
# File 'lib/openstax/aws/secrets_factory.rb', line 96

def format(&block)
  store_attribute(:format, &block)
end

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



104
105
106
107
108
# File 'lib/openstax/aws/secrets_factory.rb', line 104

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