Class: DataMapper::Transaction

Class | DataMapper::Transaction
In: | lib/dm-core/transaction.rb
Parent: | Object

### Methods

begin commit link method_missing new primitive_for rollback within

### Classes and Modules

Module DataMapper::Transaction::Adapter
Module DataMapper::Transaction::Model
Module DataMapper::Transaction::Repository
Module DataMapper::Transaction::Resource

### Constants

MysqlAdapter | = | PostgresAdapter = Sqlite3Adapter = OracleAdapter = Adapter |  | alias the MySQL, PostgreSQL, Sqlite3 and Oracle adapters to use transactions

### Public Class methods

new(*things) {|*block_args| ...}

Create a new Transaction

@see Transaction#link

In fact, it just calls link with the given arguments at the end of the constructor.

@api public

### Public Instance methods

begin()

Begin the transaction

Before begin is called, the transaction is not valid and can not be used.

@api private

commit() {|*block_args| ...}

Commit the transaction

      If no block is given, it will simply commit any changes made since the
      Transaction did #begin.

@param block<Block> a block (taking the one argument, the Transaction) to

      execute within this transaction. The transaction will begin and commit
      around the block, and roll back if an exception is raised.

@api private

link(*things) {|*block_args| ...}

Associate this Transaction with some things.

@param [Object] things

      the things you want this Transaction associated with:

      Adapters::AbstractAdapter subclasses will be added as
        adapters as is.
      Arrays will have their elements added.
      Repository will have it's own @adapters added.
      Resource subclasses will have all the repositories of all
        their properties added.
      Resource instances will have all repositories of all their
        properties added.

@param [Proc] block

      a block (taking one argument, the Transaction) to execute within
      this transaction. The transaction will begin and commit around
      the block, and rollback if an exception is raised.

@api private

method_missing(meth, *args, &block)

TODO: document @api private

primitive_for(adapter)

TODO: document @api private

rollback()

Rollback the transaction

Will undo all changes made during the transaction.

@api private

within() {|self| ...}

Execute a block within this Transaction.

No begin, commit or rollback is performed in within, but this Transaction will pushed on the per thread stack of transactions for each adapter it is associated with, and it will ensures that it will pop the Transaction away again after the block is finished.

@param block<Block> the block of code to execute.

@api private

[Validate]