Sha256: 693cefd549508863a20f5c9f03b724c953bbab94a1868328cb0f3d9bd679bfff
Contents?: true
Size: 423 Bytes
Versions: 3
Compression:
Stored size: 423 Bytes
Contents
require "ostruct" module SimpleAnalyticsApi 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
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
simple_analytics_api-0.0.3 | lib/simple_analytics_api/object.rb |
simple_analytics_api-0.0.2 | lib/simple_analytics_api/object.rb |
simple_analytics_api-0.0.1 | lib/simple_analytics_api/object.rb |