Sha256: 36d153174ac74dae688a761082a69d1d12cf5f5cc3331d06b48afc7e171a30e3
Contents?: true
Size: 406 Bytes
Versions: 1
Compression:
Stored size: 406 Bytes
Contents
module Intercom module HashableObject def from_hash(hash) hash.each do |key,value| setter_method = "#{key.to_s}=" self.send(setter_method, value) if self.respond_to?(setter_method) end end def to_hash instance_variables.inject({}) do |hash, var| hash[var.to_s.delete("@").to_sym] = instance_variable_get(var) hash end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
intercom-0.1.8 | lib/intercom/hashable_object.rb |