Class: RecursiveStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- RecursiveStruct
- Defined in:
- lib/recursive_struct.rb,
lib/recursive_struct/version.rb
Constant Summary collapse
- VERSION =
"0.0.2"
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ RecursiveStruct
constructor
A new instance of RecursiveStruct.
Constructor Details
#initialize(hash = nil) ⇒ RecursiveStruct
Returns a new instance of RecursiveStruct.
2 3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/recursive_struct.rb', line 2 def initialize(hash = nil) @table = {} if hash hash.each do |key, value| value = self.class.new(value) if value.is_a?(Hash) @table[key.to_sym] = value new_ostruct_member(key) end end end |