6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/activerecord_bulkoperation/adapters/abstract_adapter.rb', line 6
def self.included(base)
base.class_eval do
alias_method :commit_db_transaction_without_callback, :commit_db_transaction
alias_method :rollback_db_transaction_without_callback, :rollback_db_transaction
alias_method :rollback_to_savepoint_without_callback, :rollback_to_savepoint
alias_method :create_savepoint_without_callback, :create_savepoint
def commit_db_transaction
connection_listeners.select{|l| l.respond_to?('before_commit') }.each{|l| l.before_commit}
commit_db_transaction_without_callback
connection_listeners.select{|l| l.respond_to?('after_commit') }.each{|l| l.after_commit}
end
def rollback_db_transaction
rollback_db_transaction_without_callback
connection_listeners.select{|l| l.respond_to?('after_rollback') }.each{|l| l.after_rollback}
end
def rollback_to_savepoint(name = current_savepoint_name)
rollback_to_savepoint_without_callback(name)
connection_listeners.select{|l| l.respond_to?('after_rollback_to_savepoint') }.each{|l| l.after_rollback_to_savepoint}
end
def create_savepoint(name = current_savepoint_name)
connection_listeners.select{|l| l.respond_to?('before_create_savepoint') }.each{|l| l.before_create_savepoint}
create_savepoint_without_callback(name)
end
end
end
|