Class: Factor::Runtime::DeepStruct
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- Factor::Runtime::DeepStruct
- Defined in:
- lib/runtime.rb
Instance Method Summary collapse
- #[](idx) ⇒ Object
-
#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.
147 148 149 150 151 152 153 154 155 156 157 158 159 |
# File 'lib/runtime.rb', line 147 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
#[](idx) ⇒ Object
165 166 167 168 |
# File 'lib/runtime.rb', line 165 def [](idx) hash = marshal_dump hash[idx.to_sym] end |
#to_h ⇒ Object
161 162 163 |
# File 'lib/runtime.rb', line 161 def to_h @hash_table end |