Class: DatabaseCleaner::ActiveRecord::Transaction

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/database_cleaner/active_record/transaction.rb

Instance Attribute Summary

Attributes included from Base

#connection_hash

Instance Method Summary collapse

Methods included from Base

#connection_klass, #create_connection_klass, #db, #db=, #load_config

Methods included from Generic::Base

#db, included

Instance Method Details

#cleanObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/database_cleaner/active_record/transaction.rb', line 16

def clean
  return unless connection_klass.connection.open_transactions > 0

  connection_klass.connection.rollback_db_transaction

  if connection_klass.connection.respond_to?(:decrement_open_transactions)
    connection_klass.connection.decrement_open_transactions
  else
    connection_klass.__send__(:decrement_open_transactions)
  end
end

#startObject



6
7
8
9
10
11
12
13
# File 'lib/database_cleaner/active_record/transaction.rb', line 6

def start
  if connection_klass.connection.respond_to?(:increment_open_transactions)
    connection_klass.connection.increment_open_transactions
  else
    connection_klass.__send__(:increment_open_transactions)
  end
  connection_klass.connection.begin_db_transaction
end