Class: Phobos::DeepStruct
- Inherits:
- 
      OpenStruct
      
        - Object
- OpenStruct
- Phobos::DeepStruct
 
- Defined in:
- lib/phobos/deep_struct.rb
Instance Method Summary collapse
- #initialize(hash = nil) ⇒ DeepStruct constructor
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(hash = nil) ⇒ DeepStruct
| 8 9 10 11 12 13 14 15 16 17 18 19 | # File 'lib/phobos/deep_struct.rb', line 8 def initialize(hash=nil) @table = {} @hash_table = {} if hash hash.each_pair do |k, v| k = k.to_sym @table[k] = to_deep_struct(v) @hash_table[k] = v end end end | 
Instance Method Details
#to_h ⇒ Object Also known as: to_hash
| 21 22 23 | # File 'lib/phobos/deep_struct.rb', line 21 def to_h @hash_table.dup end |