Improvements for ExtendedDocument initializer

* Tries to send arg= to the Document before setting the attribute

Signed-off-by: Matt Aimonetti <mattaimonetti@gmail.com>
This commit is contained in:
Mutwin Kraus 2009-04-23 12:24:38 +08:00 committed by Matt Aimonetti
parent 6fca60ebe4
commit 75a5018b12
3 changed files with 30 additions and 3 deletions

View file

@ -126,4 +126,4 @@ module CouchRest
end
end
end
end

View file

@ -33,6 +33,11 @@ module CouchRest
def initialize(passed_keys={})
apply_defaults # defined in CouchRest::Mixins::Properties
passed_keys.each do |k,v|
if self.respond_to?("#{k}=")
self.send("#{k}=", passed_keys.delete(k))
end
end if passed_keys
super
cast_keys # defined in CouchRest::Mixins::Properties
unless self['_id'] && self['_rev']
@ -212,4 +217,4 @@ module CouchRest
end
end
end
end