1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

better behaved models for undefined attributes

only effects merge_attributes (and therefore initialize)
for any non-attributes (except collection/connection),
values just get trown into model#attributes,
but won't show up as accessors or in inspect, etc.
Results in no errors, but implies that the attributes SHOULD be added.
This commit is contained in:
geemus 2010-10-27 16:16:22 -07:00
parent 7f38159f7b
commit 3c8e45ec15

View file

@ -118,11 +118,13 @@ module Fog
end
def attributes
attributes = {}
for attribute in self.class.attributes
attributes[attribute] = send("#{attribute}")
@attributes ||= begin
attributes = {}
for attribute in self.class.attributes
attributes[attribute] = send("#{attribute}")
end
attributes
end
attributes
end
def identity
@ -138,8 +140,10 @@ module Fog
unless self.class.ignored_attributes.include?(key)
if aliased_key = self.class.aliases[key]
send("#{aliased_key}=", value)
else
elsif (self.class.attributes | [:collection, :connection]).include?(key)
send("#{key}=", value)
else
attributes.merge!(key => value)
end
end
end