On Jan 15, 2014 2:43 AM, "Jeremy Evans" <[email protected]> wrote:
>
> The way the instance_hooks plugin currently works is that after the after
hooks of a given type run, it clears both the after and before hooks for
that type.  So the before_validation and after_validation instance hooks
get cleared after the after_validation instance hooks run, which is before
save.  However, this behavior is not specced, it is an implementation
detail.  It can and probably should be changed to not clear the validation
instance hooks until after a successful save.  I'll implement that soon.
>
I considered doing that also, clearing on a successful save or destroy but
I thought explicit removal was more flexible and allows both one shot and
hanging around until some specific condition e.g. save/destroy on an
associated model succeeding. However when there is an exception or save
failure for any reason there is probably little point keeping hooks around
because the model graph can be in an indeterminate state that can't easily
be recovered from without reloading.

I will implement automatic clearing of hooks in
after_transaction_commit/after_transaction_rollback and
after_destroy_commit/after_destroy_rollback and see how that goes in my use
cases.

Regards... Andrew

-- 
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.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to