Use case is library code that wants to force a raise on failure without changing any permanent state. For example, a "railsify" plugin that makes sequel models behave more like ActiveRecord models wants to define a save! method that always raises on failure, while not perturbing the behavior of save.
Patch is attached. Most invasive bit is adding an optional opts argument to valid?, which could break in cases where it was overridden (as some specs did). On Mon, Nov 23, 2009 at 9:45 AM, Jeremy Evans <[email protected]> wrote: > On Nov 23, 9:09 am, John Firebaugh <[email protected]> wrote: >> Hey Jeremy, >> >> This change is working great for me, thanks. I do have one followup: I >> have several places in library code where I need to do something like: >> >> begin >> old_raise_on_save_failure, object.raise_on_save_failure = >> object.raise_on_save_failure, true >> object.save >> ensure >> object.raise_on_save_failure = old_raise_on_save_failure >> end >> >> Would you accept a patch for save/destroy to support a >> :raise_on_failure option, so this pattern can be replaced with: >> >> object.save(:raise_on_failure => true) > > Is the use case for this so the object could be saved later with the > original setting in effect? > > I guess I'm OK with this change if it doesn't complicate things too > much. > > Thanks, > Jeremy > > -- > > You received this message because you are subscribed to the Google Groups > "sequel-talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sequel-talk?hl=. > > > -- You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=.
0001-Support-a-raise_on_failure-option-for-save-and-destr.patch
Description: Binary data
