Sha256: e0b06bda13c161b257b4a44d99bfc831acd54f7606b36dddd827ba94e2e2c157
Contents?: true
Size: 415 Bytes
Versions: 2
Compression:
Stored size: 415 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
pirsch_api-0.1.1 | lib/pirsch_api/object.rb |
pirsch_api-0.1.0 | lib/pirsch_api/object.rb |