/usr/lib/ruby/vendor_ruby/em-synchrony/activerecord_4_2.rb is in ruby-em-synchrony 1.0.5-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | require 'active_record'
module EM::Synchrony
module ActiveRecord
module Adapter_4_2
def configure_connection
nil
end
def transaction(*args)
@connection.execute(false) do |conn|
super
end
end
def reset_transaction #:nodoc:
@transaction_manager = TransactionManager.new(self)
end
end
class TransactionManager < ::ActiveRecord::ConnectionAdapters::TransactionManager
def initialize(*args)
super
@stack = Hash.new { |h, k| h[k] = [] }
end
def current_transaction #:nodoc:
_current_stack.last || NULL_TRANSACTION
end
def open_transactions
_current_stack.size
end
def begin_transaction(options = {}) #:nodoc:
transaction =
if _current_stack.empty?
::ActiveRecord::ConnectionAdapters::RealTransaction.new(@connection, options)
else
::ActiveRecord::ConnectionAdapters::SavepointTransaction.new(@connection, "active_record_#{Fiber.current.object_id}_#{open_transactions}", options)
end
_current_stack.push(transaction)
transaction
end
def commit_transaction #:nodoc:
_current_stack.pop.commit
end
def rollback_transaction #:nodoc:
_current_stack.pop.rollback
end
private
def _current_stack
@stack[Fiber.current.object_id]
end
end
end
end
|