Module: DataMapper::Transaction::Adapter

Extended by:
Chainable
Defined in:
lib/dm-core/transaction.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Chainable

chainable, extendable

Class Method Details

.included(base) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO: document



343
344
345
346
347
# File 'lib/dm-core/transaction.rb', line 343

def self.included(base)
  [ :Repository, :Model, :Resource ].each do |name|
    DataMapper.const_get(name).send(:include, Transaction.const_get(name))
  end
end

Instance Method Details

#current_transactionTransaction

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Retrieve the current transaction for this Adapter.

Everything done by this Adapter is done within the context of this Transaction.

Returns:

  • (Transaction)

    the ‘current’ transaction for this Adapter.



398
399
400
# File 'lib/dm-core/transaction.rb', line 398

def current_transaction
  transactions.last
end

#pop_transactionTransaction

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pop the ‘current’ Transaction from the per thread Transaction stack so that everything done by this Adapter is no longer necessarily within the context of said Transaction.

Returns:

  • (Transaction)

    the former ‘current’ transaction.



385
386
387
# File 'lib/dm-core/transaction.rb', line 385

def pop_transaction
  transactions.pop
end

#push_transaction(transaction) ⇒ Array(Transaction)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Pushes the given Transaction onto the per thread Transaction stack so that everything done by this Adapter is done within the context of said Transaction.

Parameters:

  • transaction (Transaction)

    a Transaction to be the ‘current’ transaction until popped.

Returns:

  • (Array(Transaction))

    the stack of active transactions for the current thread



373
374
375
# File 'lib/dm-core/transaction.rb', line 373

def push_transaction(transaction)
  transactions << transaction
end

#transaction_primitiveObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Produces a fresh transaction primitive for this Adapter

Used by Transaction to perform its various tasks.

Returns:

  • (Object)

    a new Object that responds to :close, :begin, :commit, and :rollback,



358
359
360
# File 'lib/dm-core/transaction.rb', line 358

def transaction_primitive
  DataObjects::Transaction.create_for_uri(normalized_uri)
end