lambda in couchrest::model default_obj Revision 313866316631 (Wed Nov 16 2011 at 05:11) - Diff Link to this snippet: https://friendpaste.com/5Tfs4mTgcRe9qCQx03a2jM Embed: manni perldoc borland colorful default murphy trac fruity autumn bw emacs pastie friendly Show line numbers Wrap lines 123456789101112131415161718# /lib/couchrest/core/model.rb line 526# usage: # set_default :random => lambda { return rand(99) }, :random2 => lambda { return rand(99) }, :test => true, :str => 'string'privatedef apply_defaults if self.class.default self.class.default.each do |k,v| if v.class == Proc self[k.to_s] = v.call else self[k.to_s] = Marshal.load(Marshal.dump(v)) end end endend