diff --git a/lib/couchrest/core/model.rb b/lib/couchrest/core/model.rb index 2d5207a..755acda 100644 --- a/lib/couchrest/core/model.rb +++ b/lib/couchrest/core/model.rb @@ -510,6 +510,11 @@ module CouchRest if self.class.default self.class.default.each do |k,v| self[k] = v unless self.key?(k.to_s) + if v.class == Proc + self[k.to_s] = v.call + else + self[k.to_s] = Marshal.load(Marshal.dump(v)) + end end end end diff --git a/lib/couchrest/monkeypatches.rb b/lib/couchrest/monkeypatches.rb index 58b8fe9..da676d7 100644 --- a/lib/couchrest/monkeypatches.rb +++ b/lib/couchrest/monkeypatches.rb @@ -8,7 +8,7 @@ class Time def to_json(options = nil) u = self.utc - %("#{u.strftime("%Y/%m/%d %H:%M:%S +0000")}") + %("#{u.strftime("%Y/%m/%d %H:%M:%S.#{u.usec} +0000")}") end # Decodes the JSON time format to a UTC time.