module

Ralph::Transactions

Transaction support for models

This module provides transaction management capabilities including:

  • Model-level transactions (Model.transaction { ... })
  • Nested transaction support (savepoints)
  • Transaction callbacks (after_commit, after_rollback)

Example:

User.transaction do
  user1 = User.create(name: "Alice")
  user2 = User.create(name: "Bob")
  # Both will be saved or both will be rolled back
end

Class methods

after_commit

Register an after_commit callback

Source
after_rollback

Register an after_rollback callback

Source
clear_transaction_callbacks

Clear all transaction callbacks

Source
in_transaction?

Check if currently in a transaction

Source
run_after_commit_callbacks

Run after_commit callbacks

Source
run_after_rollback_callbacks

Run after_rollback callbacks

Source
transaction_committed=(value : Bool)

Setter for transaction committed state

Source
transaction_committed?

Check if the current transaction is committed (not rolled back)

Source
transaction_depth

Get the current transaction depth

Source
transaction_depth=(value : Int32)

Increment transaction depth

Source