module Sequel::Database::RunTransactionHooks
Public Instance Methods
Source
# File lib/sequel/extensions/run_transaction_hooks.rb 34 def run_after_commit_hooks(opts=OPTS) 35 _run_transaction_hooks(:after_commit, opts) 36 end
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.
Source
# File lib/sequel/extensions/run_transaction_hooks.rb 42 def run_after_rollback_hooks(opts=OPTS) 43 _run_transaction_hooks(:after_rollback, opts) 44 end
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.
Private Instance Methods
Source
# File lib/sequel/extensions/run_transaction_hooks.rb 48 def _run_transaction_hooks(type, opts) 49 synchronize(opts[:server]) do |conn| 50 unless h = _trans(conn) 51 raise Sequel::Error, "Cannot call run_#{type}_hooks outside of a transaction" 52 end 53 54 if hooks = h[type] 55 hooks.each(&:call) 56 hooks.clear 57 end 58 59 if (savepoints = h[:savepoints]) 60 savepoints.each do |savepoint| 61 if hooks = savepoint[type] 62 hooks.each(&:call) 63 hooks.clear 64 end 65 end 66 end 67 end 68 end