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)


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

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



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

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

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



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

def attributes
  @attributes
end

Instance Method Details

#format(&block) ⇒ Object



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

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

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



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

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