Class: JsonStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- JsonStruct
- Defined in:
- lib/phonegap_build/deep_struct.rb
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ JsonStruct
constructor
A new instance of JsonStruct.
- #to_h ⇒ Object
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_h ⇒ Object
21 22 23 |
# File 'lib/phonegap_build/deep_struct.rb', line 21 def to_h @hash_table end |