Sha256: 7c24b2a8cb28cf98b021fb0e19b11c6bf879e06d801ee7e6dc689832ad445f43
Contents?: true
Size: 576 Bytes
Versions: 14
Compression:
Stored size: 576 Bytes
Contents
module Intercom module HashableObject def from_hash(hash) hash.each {|attribute, value| instance_variable_set("@#{attribute}".to_sym, value) } end def to_hash instance_variables.inject({}) do |hash, var| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) hash end end def displayable_attributes Hash[ to_hash.select {|attribute, value| self.respond_to?(attribute) } ] end def to_wire Hash[ to_hash.select {|attribute, value| self.respond_to?("#{attribute.to_s}=") } ] end end end
Version data entries
14 entries across 14 versions & 1 rubygems