Sha256: 4f0c77cf7ac4e2098c7607d9391f02cce17aa0d2d1341f66c7b7cc4bc2b9ff8a
Contents?: true
Size: 414 Bytes
Versions: 4
Compression:
Stored size: 414 Bytes
Contents
require "ostruct" module PirschApi class Object < OpenStruct def initialize(attributes) super to_ostruct(attributes) end def to_ostruct(obj) if obj.is_a?(Hash) OpenStruct.new(obj.map { |key, val| [key, 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 end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
pirsch_api-0.0.5 | lib/pirsch_api/object.rb |
pirsch_api-0.0.4 | lib/pirsch_api/object.rb |
pirsch_api-0.0.3 | lib/pirsch_api/object.rb |
pirsch_api-0.0.2 | lib/pirsch_api/object.rb |