On Monday, March 2, 2015 at 5:24:12 PM UTC+10:30, Jeremy Evans wrote:
>
> I apologize if I seem combative about this. It's just that I have an 
> accounting and auditing background and the specific example you gave threw 
> up red flags. :)   It's possible that before_commit could have some useful 
> applications, though I can't think of a good example off the top of my head.
>

No problems, I understand the instinct. My specific use case is for Sqlite 
which does not support deferred constraints (except foreign key 
constraints) and so I would like to do as much checking in the Model as 
possible, if only to catch programming errors in testing. You concerns 
about auditing, while well founded, also don't apply to my specific 
application. :)

Attached is my first attempt at a before_commit extension, drawing on your 
suggestions and the implementation of after_commit. I have made it so that 
before_commit must only be called inside a transaction and will raise an 
error if it is not, but I could enhance it so that the invoker could choose 
between this an the run-immediately behaviour of after_commit, although I'm 
not sure which should be the default. I appreciate your thoughts and 
feedback.

Thanks,
Tim 

-- 
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/d/optout.

Attachment: before_commit.rb
Description: Binary data

Reply via email to