Module: DataMapper::Adapters::AbstractAdapter::Transaction
- Included in:
- DataMapper::Adapters::AbstractAdapter
- Defined in:
- lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb
Overview
TODO: move to dm-more/dm-transaction
Instance Method Summary collapse
-
#current_transaction ⇒ DataMapper::Transaction
Retrieve the current transaction for this Adapter.
-
#pop_transaction ⇒ DataMapper::Transaction
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.
-
#push_transaction(transaction) ⇒ Object
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.
-
#transaction_primitive ⇒ Object
Produces a fresh transaction primitive for this Adapter.
-
#within_transaction? ⇒ Boolean
Returns whether we are within a Transaction.
Instance Method Details
#current_transaction ⇒ DataMapper::Transaction
Retrieve the current transaction for this Adapter.
Everything done by this Adapter is done within the context of this Transaction.
TODO: move to dm-more/dm-transaction
166 167 168 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb', line 166 def current_transaction transactions(Thread.current).last end |
#pop_transaction ⇒ DataMapper::Transaction
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.
TODO: move to dm-more/dm-transaction
153 154 155 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb', line 153 def pop_transaction transactions(Thread.current).pop end |
#push_transaction(transaction) ⇒ Object
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.
TODO: move to dm-more/dm-transaction
141 142 143 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb', line 141 def push_transaction(transaction) transactions(Thread.current) << transaction end |
#transaction_primitive ⇒ Object
Produces a fresh transaction primitive for this Adapter
Used by DataMapper::Transaction to perform its various tasks.
TODO: move to dm-more/dm-transaction (if possible)
189 190 191 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb', line 189 def transaction_primitive raise NotImplementedError end |
#within_transaction? ⇒ Boolean
Returns whether we are within a Transaction.
TODO: move to dm-more/dm-transaction
176 177 178 |
# File 'lib/gems/dm-core-0.9.9/lib/dm-core/adapters/abstract_adapter.rb', line 176 def within_transaction? !current_transaction.nil? end |