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
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/phobos/deep_struct.rb', line 10 def initialize(hash = nil) @table = {} @hash_table = {} hash&.each_pair do |key, value| key = key.to_sym @table[key] = to_deep_struct(value) @hash_table[key] = value 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 |