Class: OpenStruct

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

Instance Method Summary collapse

Constructor Details

#initialize(hsh) ⇒ OpenStruct

Returns a new instance of OpenStruct.



14
15
16
# File 'lib/wp_config.rb', line 14

def initialize(hsh)
  @hsh = hsh
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/wp_config.rb', line 6

def method_missing(method)
  method = method.to_s
  if @hsh[method].is_a? Hash
    OpenStruct.new(@hsh[method])
  else
    @hsh[method]
  end
end