Class: EasyConfig::DeepStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- EasyConfig::DeepStruct
- Defined in:
- lib/easy_config/deep_struct.rb
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ DeepStruct
constructor
A new instance of DeepStruct.
- #to_h ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ DeepStruct
Returns a new instance of DeepStruct.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/easy_config/deep_struct.rb', line 6 def initialize(hash=nil) @table = {} @hash_table = {} if hash hash.each do |k,v| @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 end |
Instance Method Details
#to_h ⇒ Object
20 21 22 |
# File 'lib/easy_config/deep_struct.rb', line 20 def to_h @hash_table end |