Class: JsonStruct

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/phonegap_build/deep_struct.rb

Instance Method Summary collapse

Constructor Details

#initialize(hash = nil) ⇒ JsonStruct

Returns a new instance of JsonStruct.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/phonegap_build/deep_struct.rb', line 7

def initialize(hash = nil)
  @table = {}
  @hash_table = {}

  return unless hash
  hash.each do |k, v|
    recursive_initializer(v) if v.is_a?(Array)

    @table[k.to_sym] = (v.is_a?(Hash) ? self.class.new(v) : v)
    @hash_table[k.to_sym] = v
    new_ostruct_member(k)
  end
end

Instance Method Details

#to_hObject



21
22
23
# File 'lib/phonegap_build/deep_struct.rb', line 21

def to_h
  @hash_table
end