modified apply_defaults in CouchRest::Model to allow Procs in defaults and to safely clone (not reference) defaults from the class variable

This commit is contained in:
Sho Fukamachi 2008-11-30 12:40:01 +11:00
parent 313aae3e3d
commit 0c527baa25

View file

@ -526,7 +526,11 @@ module CouchRest
def apply_defaults def apply_defaults
if self.class.default if self.class.default
self.class.default.each do |k,v| self.class.default.each do |k,v|
self[k] = v if v.class == Proc
self[k.to_s] = v.call
else
self[k.to_s] = Marshal.load(Marshal.dump(v))
end
end end
end end
end end