Class: OpenStruct
- Inherits:
-
Object
- Object
- OpenStruct
- Defined in:
- lib/ostruct_nested.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_json(json_string) ⇒ Object
15 16 17 |
# File 'lib/ostruct_nested.rb', line 15 def self.from_json(json_string) JSON.parse(json_string, object_class: OpenStruct) end |
Instance Method Details
#to_h_nested ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/ostruct_nested.rb', line 5 def to_h_nested hash = self.to_h hash.each do |key, value| if value.is_a? OpenStruct hash[key] = value.to_h_nested end end hash end |