lib/intercom/hashable_object.rb in intercom-0.1.9 vs lib/intercom/hashable_object.rb in intercom-0.1.10

- old
+ new

@@ -1,20 +1,22 @@ module Intercom module HashableObject def from_hash(hash) - hash.each do |key,value| - instance_variable_set("@#{key}".to_sym, value) - end + 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 - to_hash.delete_if {|k, v| !self.respond_to?(k) } + to_hash.select {|attribute, value| self.respond_to?(attribute) } + end + + def to_wire + to_hash.select {|attribute, value| self.respond_to?("#{attribute.to_s}=") } end end end \ No newline at end of file