Class: Testcloud::Config::Configuration

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/testcloud/config/configuration.rb

Overview

thin wrapper around the internal hash representation object

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ Configuration

Returns a new instance of Configuration.



16
17
18
# File 'lib/testcloud/config/configuration.rb', line 16

def initialize(hash)
  @hash = hash.respond_to?(:with_indifferent_access) ? hash.with_indifferent_access : hash
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &block) ⇒ Object (protected)



22
23
24
25
26
27
28
29
30
# File 'lib/testcloud/config/configuration.rb', line 22

def method_missing(method_name, *args, &block)
  method_name = method_name.to_s[0..-2] if method_name.to_s[-1] == '?'
  if key?(method_name)
    value = hash[method_name]
    value.is_a?(Hash) ? Testcloud::Config::Configuration.new(value) : value
  else
    super(method_name, *args, &block)
  end
end

Instance Attribute Details

#hashObject (readonly)

Returns the value of attribute hash.



12
13
14
# File 'lib/testcloud/config/configuration.rb', line 12

def hash
  @hash
end