whiny_find(*args) :-D
What about sticking with find, but pass an argument, say ":except => true" in when we want the behavior to raise an exception instead of returning nil? or perhaps: findx(*args) (find with eXception) Michael On Tue, Mar 12, 2013 at 8:25 PM, Jeremy Evans <[email protected]> wrote: > Sequel::Model does not currently have a method for finding the first > matching instance or raising an exception. Historically, the methods that > return individual rows return nil if no rows match. I think that's a good > default, but in some cases you want an error to be raised (akin to > ActiveRecord::RecordNotFound). > > I'd like this method to basically be the following code: > > def (Sequel::Model).METHOD_NAME(*args) > self[*args] || raise Sequel::EXCEPTION_NAME > end > > My main concern when adding this method is naming. What should the method > and exception names be? > > Method naming is problematic. .find is already used and works differently, > same with .first. Using .find! or .first! is problematic as that implies > the method works just like .find or .first, and .[] operates differently. > .[]! is not valid syntax. If anyone has suggestions for the method name, > please speak up. > > Exception naming I'm not very concerned with. We could be just like > ActiveRecord and use Sequel::RecordNotFound, but I'm open to suggestions > there as well. > > Thanks, > Jeremy > > -- > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/sequel-talk?hl=en. > For more options, visit https://groups.google.com/groups/opt_out. > > -- http://codeconnoisseur.org -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sequel-talk?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
