apply sho's patch: default values may be lambdas

This commit is contained in:
Chris Anderson 2009-01-12 20:45:07 -08:00
commit 5e7f61d332
2 changed files with 6 additions and 1 deletions

View file

@ -510,6 +510,11 @@ module CouchRest
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 unless self.key?(k.to_s) 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 end
end end

View file

@ -8,7 +8,7 @@ class Time
def to_json(options = nil) def to_json(options = nil)
u = self.utc u = self.utc
%("#{u.strftime("%Y/%m/%d %H:%M:%S +0000")}") %("#{u.strftime("%Y/%m/%d %H:%M:%S.#{u.usec} +0000")}")
end end
# Decodes the JSON time format to a UTC time. # Decodes the JSON time format to a UTC time.