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
- .new ⇒ Transaction constructor Internal use only
Instance Method Summary
-
#after_commit(&block)
Registers a block to be called after the current transaction is fully committed.
-
#after_rollback(&block)
Registers a block to be called after the current transaction is rolled back.
-
#before_commit(&block)
Registers a block to be called before the current transaction is fully committed.
- #append_callbacks(callbacks) protected
Constructor Details
.new ⇒ Transaction
# 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.
#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.
#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.