On Tue, Mar 29, 2011 at 04:19:10PM +0200, Simone Carletti wrote:
> >
> > The storage methods may seem weird. The general rule for the #put and
> > #delete method is
> >
> >  - return nil when success
> >  - return true when the record is gone (update/deletion failed)
> >  - return the current version of the record when the caller's version is
> >    out of date (and there is a current version).
> 
> Oh, great. Now everything is a little bit more clear.
> 
> do_it(record) && raise ArgumentError.new("record out of date or gone")
> 
> Well, you can reverse the statement and say
> 
> do_it(record) || raise ArgumentError.new("record out of date or gone")
> 
> The second statement can also take advantage of the fact that in Ruby only
> false/nil evaluates to false in a boolean comparison.

Well, let me simplify the thinking behind this to

  "if it returns something that evaluates to true (or true), then something
   went wrong"

Sorry if it's not intuitive. I really want to return the record when it's out 
of date and I don't want to trick Ruby's conditionals into thinking that a Hash 
evaluates to false.


Best regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to