Sha256: 0537dc7d16518e2c7ef8f2d4e5cba98a1d37b280f852f9ac72fad8e8ac8d0933
Contents?: true
Size: 598 Bytes
Versions: 1
Compression:
Stored size: 598 Bytes
Contents
require "ostruct" module Calendly class Object < OpenStruct def initialize(attributes) super to_ostruct(attributes.merge(uuid: extract_uuid(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 def extract_uuid(attrs) attrs["uri"] ? get_slug(attrs["uri"]) : nil end def get_slug(path) path.split("/").last end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
calendlyr-0.3.3 | lib/calendly/object.rb |