From 0c527baa254cf617aa463e02b93e28dce29787b0 Mon Sep 17 00:00:00 2001 From: Sho Fukamachi Date: Sun, 30 Nov 2008 12:40:01 +1100 Subject: [PATCH] modified apply_defaults in CouchRest::Model to allow Procs in defaults and to safely clone (not reference) defaults from the class variable --- lib/couchrest/core/model.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/couchrest/core/model.rb b/lib/couchrest/core/model.rb index 0fccb27..9d38cb8 100644 --- a/lib/couchrest/core/model.rb +++ b/lib/couchrest/core/model.rb @@ -526,7 +526,11 @@ module CouchRest def apply_defaults if self.class.default 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