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
1 changed files with 5 additions and 1 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue