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:
parent
313aae3e3d
commit
0c527baa25
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue