class ServicesTestServer::DbController
Public Class Methods
new()
click to toggle source
# File lib/services_test_server/db_controller.rb, line 16 def initialize @mutex = Mutex.new end
only_one_connection()
click to toggle source
# File lib/services_test_server/db_controller.rb, line 6 def self.only_one_connection ActiveRecord::ConnectionAdapters::ConnectionPool.class_eval do alias_method :old_checkout, :checkout def checkout @cached_connection ||= old_checkout end end end
Public Instance Methods
begin_transaction()
click to toggle source
# File lib/services_test_server/db_controller.rb, line 20 def begin_transaction @mutex.lock ServicesTestServer.logger.debug "Beginning remote transaction" ActiveRecord::Base.connection.begin_transaction(joinable: false) end
checkout()
click to toggle source
# File lib/services_test_server/db_controller.rb, line 10 def checkout @cached_connection ||= old_checkout end
rollback_transaction()
click to toggle source
# File lib/services_test_server/db_controller.rb, line 26 def rollback_transaction ServicesTestServer.logger.debug "Rolling back remote transaction" ActiveRecord::Base.connection.rollback_transaction @mutex.unlock end