Method: Cin7API::Object#to_ostruct
- Defined in:
- lib/cin7_api/object.rb
#to_ostruct(obj) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/cin7_api/object.rb', line 12 def to_ostruct(obj) if obj.is_a?(Hash) OpenStruct.new(obj.map { |key, val| [key.underscore, to_ostruct(val)] }.to_h) elsif obj.is_a?(Array) obj.map { |o| to_ostruct(o) } else # Assumed to be a primitive value obj end end |