Sha256: 831dc91d8cb81fb52167fcb59c415ba11ad961bff83f388a8fc6ac72c479cf23
Contents?: true
Size: 502 Bytes
Versions: 4
Compression:
Stored size: 502 Bytes
Contents
# frozen_string_literal: true require 'active_support/core_ext/string' require 'ostruct' module CustomerioAPI 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.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 end end
Version data entries
4 entries across 4 versions & 1 rubygems