From 3c8e45ec156a15ecccdd63f4b2b7a8576d35507b Mon Sep 17 00:00:00 2001 From: geemus Date: Wed, 27 Oct 2010 16:16:22 -0700 Subject: [PATCH] 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. --- lib/fog/core/attributes.rb | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/lib/fog/core/attributes.rb b/lib/fog/core/attributes.rb index f22151111..2eef3c970 100644 --- a/lib/fog/core/attributes.rb +++ b/lib/fog/core/attributes.rb @@ -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