fixup default handling
This commit is contained in:
parent
7d6f3e0ced
commit
4c6d12fb6a
|
@ -4,9 +4,9 @@ require 'digest/md5'
|
||||||
require File.dirname(__FILE__) + '/document'
|
require File.dirname(__FILE__) + '/document'
|
||||||
require 'mime/types'
|
require 'mime/types'
|
||||||
|
|
||||||
# = CouchRest::Model - ORM, the CouchDB way
|
# = CouchRest::Model - Document modeling, the CouchDB way
|
||||||
module CouchRest
|
module CouchRest
|
||||||
# = CouchRest::Model - ORM, the CouchDB way
|
# = CouchRest::Model - Document modeling, the CouchDB way
|
||||||
#
|
#
|
||||||
# CouchRest::Model provides an ORM-like interface for CouchDB documents. It
|
# CouchRest::Model provides an ORM-like interface for CouchDB documents. It
|
||||||
# avoids all usage of <tt>method_missing</tt>, and tries to strike a balance
|
# avoids all usage of <tt>method_missing</tt>, and tries to strike a balance
|
||||||
|
@ -550,11 +550,12 @@ module CouchRest
|
||||||
return unless new_document?
|
return unless new_document?
|
||||||
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)
|
unless self.key?(k.to_s)
|
||||||
if v.class == Proc
|
if v.class == Proc
|
||||||
self[k.to_s] = v.call
|
self[k.to_s] = v.call
|
||||||
else
|
else
|
||||||
self[k.to_s] = Marshal.load(Marshal.dump(v))
|
self[k.to_s] = Marshal.load(Marshal.dump(v))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue