module Sequel::Database::RunTransactionHooks
Public Instance Methods
run_after_commit_hooks(opts=OPTS)
click to toggle source
Run all savepoint and transaction after_commit hooks for the current transaction, and remove the hooks after running them. Options:
- :server
-
The server/shard to use.
# File lib/sequel/extensions/run_transaction_hooks.rb, line 33 def run_after_commit_hooks(opts=OPTS) _run_transaction_hooks(:after_commit, opts) end
run_after_rollback_hooks(opts=OPTS)
click to toggle source
Run all savepoint and transaction after_rollback hooks for the current transaction, and remove the hooks after running them. Options:
- :server
-
The server/shard to use.
# File lib/sequel/extensions/run_transaction_hooks.rb, line 41 def run_after_rollback_hooks(opts=OPTS) _run_transaction_hooks(:after_rollback, opts) end
Private Instance Methods
_run_transaction_hooks(type, opts)
click to toggle source
# File lib/sequel/extensions/run_transaction_hooks.rb, line 47 def _run_transaction_hooks(type, opts) synchronize(opts[:server]) do |conn| unless h = _trans(conn) raise Sequel::Error, "Cannot call run_#{type}_hooks outside of a transaction" end if hooks = h[type] hooks.each(&:call) hooks.clear end if (savepoints = h[:savepoints]) savepoints.each do |savepoint| if hooks = savepoint[type] hooks.each(&:call) hooks.clear end end end end end