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
15
16
17
# File 'lib/static_config/config_hash.rb', line 7

def method_missing(attr, *args)
  if value = @data[attr.to_s]
    if value.is_a? Hash
      ConfigHash.new value
    else
      value
    end
  else
    nil
  end
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
# File 'lib/static_config/config_hash.rb', line 19

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