class OpenStruct

Public Class Methods

from_json(json_string) click to toggle source
# File lib/ostruct_nested.rb, line 15
def self.from_json(json_string)
  JSON.parse(json_string, object_class: OpenStruct)
end

Public Instance Methods

to_h_nested() click to toggle source
# 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