Class: StaticConfig::ConfigHash

Inherits:
Object
  • Object
show all
Defined in:
lib/static_config/config_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ ConfigHash

Returns a new instance of ConfigHash.



3
4
5
# File 'lib/static_config/config_hash.rb', line 3

def initialize(data)
  @data = data
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(attr, *args) ⇒ Object



7
8
9
10
11
12
13
14
# File 'lib/static_config/config_hash.rb', line 7

def method_missing(attr, *args)
  case value = @data[attr.to_s]
  when Hash
    ConfigHash.new value
  else
    value
  end
end

Instance Method Details

#==(other) ⇒ Object



16
17
18
# File 'lib/static_config/config_hash.rb', line 16

def ==(other)
  super || @data == other
end