Sha256: 6c4e21265d203d0b0a550a5da73332071864c2bc9d62cbbe9319d9e60c2d1f72
Contents?: true
Size: 621 Bytes
Versions: 1
Compression:
Stored size: 621 Bytes
Contents
require 'ostruct' module NestedOstruct extend self def to_hash(object) object = object.to_h if object.is_a?(OpenStruct) case object.class.to_s when /Hash/ object.each do |key, value| if [Hash, Array, OpenStruct].include?(value.class) object[key] = to_hash(value) else object[key] = value end end when /Array/ object.each_with_index do |value, i| if [Hash, Array, OpenStruct].include?(value.class) object[i] = to_hash(value) else object[i] = value end end end object end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
nested_ostruct-0.0.1 | lib/nested_ostruct.rb |