lib/intercom/hashable_object.rb in intercom-0.1.8 vs lib/intercom/hashable_object.rb in intercom-0.1.9
- old
+ new
@@ -1,17 +1,20 @@
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)
+ instance_variable_set("@#{key}".to_sym, value)
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
+
+ def displayable_attributes
+ to_hash.delete_if {|k, v| !self.respond_to?(k) }
end
end
end
\ No newline at end of file