Repository URL to install this package:
|
Version:
2.2.0 ▾
|
module ObjectToHash
module_function
def to_hash_array(array_object)
hash_arrays = []
array_object.each do |object|
hash_arrays.push(OpenStruct.new(object.to_h))
end
hash_arrays
end
def deep_ostruct(obj)
case obj
when Hash
root = OpenStruct.new(obj)
obj.each_with_object(root) do |(k,v), o|
o.send("#{k}=", deep_ostruct(v))
end
root
when Array
obj.map do |v|
deep_ostruct(v)
end
else
obj
end
end
end