Class | DataMapper::Transaction |
In: |
lib/dm-core/transaction.rb
|
Parent: | Object |
adapters | [R] | |
state | [R] | |
transaction_primitives | [R] |
Create a new DataMapper::Transaction
@see DataMapper::Transaction#link
In fact, it just calls link with the given arguments at the end of the constructor.
Begin the transaction
Before begin is called, the transaction is not valid and can not be used.
Commit the transaction
@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.
@note
If no block is given, it will simply commit any changes made since the Transaction did #begin.
Associate this Transaction with some things.
@param things<any number of Object> the things you want this Transaction
associated with
@details [things a Transaction may be associatied with]
DataMapper::Adapters::AbstractAdapter subclasses will be added as adapters as is. Arrays will have their elements added. DataMapper::Repositories will have their @adapters added. DataMapper::Resource subclasses will have all the repositories of all their properties added. DataMapper::Resource instances will have all repositories of all their properties added.
@param block<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.
Execute a block within this Transaction.
@param block<Block> the block of code to execute.
@note
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.