123456789_123456789_123456789_123456789_123456789_

Class: ActiveRecord::Transaction

Relationships & Source Files
Namespace Children
Classes:
Extension / Inclusion / Inheritance Descendants
Subclasses:
Inherits: Object
Defined in: activerecord/lib/active_record/transaction.rb

Class Method Summary

Instance Method Summary

Constructor Details

.newTransaction

This method is for internal use only.
[ GitHub ]

  
# File 'activerecord/lib/active_record/transaction.rb', line 24

def initialize # :nodoc:
  @callbacks = nil
end

Instance Method Details

#after_commit(&block)

Registers a block to be called after the current transaction is fully committed.

If there is no currently open transactions, the block is called immediately.

If the current transaction has a parent transaction, the callback is transferred to the parent when the current transaction commits, or dropped when the current transaction is rolled back. This operation is repeated until the outermost transaction is reached.

[ GitHub ]

  
# File 'activerecord/lib/active_record/transaction.rb', line 46

def after_commit(&block)
  (@callbacks ||= []) << Callback.new(:after_commit, block)
end

#after_rollback(&block)

Registers a block to be called after the current transaction is rolled back.

If there is no currently open transactions, the block is never called.

If the current transaction is successfully committed but has a parent transaction, the callback is automatically added to the parent transaction.

If the entire chain of nested transactions are all successfully committed, the block is never called.

[ GitHub ]

  
# File 'activerecord/lib/active_record/transaction.rb', line 59

def after_rollback(&block)
  (@callbacks ||= []) << Callback.new(:after_rollback, block)
end

#append_callbacks(callbacks) (protected)

[ GitHub ]

  
# File 'activerecord/lib/active_record/transaction.rb', line 64

def append_callbacks(callbacks)
  (@callbacks ||= []).concat(callbacks)
end

#before_commit(&block)

Registers a block to be called before the current transaction is fully committed.

If there is no currently open transactions, the block is called immediately.

If the current transaction has a parent transaction, the callback is transferred to the parent when the current transaction commits, or dropped when the current transaction is rolled back. This operation is repeated until the outermost transaction is reached.

[ GitHub ]

  
# File 'activerecord/lib/active_record/transaction.rb', line 35

def before_commit(&block)
  (@callbacks ||= []) << Callback.new(:before_commit, block)
end