Class: DataContainer
- Inherits:
-
OpenStruct
- Object
- OpenStruct
- DataContainer
- Defined in:
- lib/datafiniti/deep_struct.rb
Instance Method Summary collapse
-
#initialize(hash = nil) ⇒ DataContainer
constructor
A new instance of DataContainer.
- #status ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(hash = nil) ⇒ DataContainer
Returns a new instance of DataContainer.
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/datafiniti/deep_struct.rb', line 9 def initialize(hash=nil) @table = Hash.new(nil) @hash_table = Hash.new(nil) 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
#status ⇒ Object
27 28 29 |
# File 'lib/datafiniti/deep_struct.rb', line 27 def status return 204 end |
#to_h ⇒ Object
23 24 25 |
# File 'lib/datafiniti/deep_struct.rb', line 23 def to_h @hash_table end |