Class: DbAgile::Core::Transaction
- Inherits:
-
Object
- Object
- DbAgile::Core::Transaction
- Defined in:
- lib/dbagile/core/transaction.rb
Instance Method Summary collapse
-
#commit ⇒ Object
Commits the transaction.
-
#execute(&block) ⇒ Object
Executes a block.
-
#initialize(connection) ⇒ Transaction
constructor
Creates a Transaction instance.
-
#rollback ⇒ Object
Rollbacks the transaction.
-
#transaction(&block) ⇒ Object
Executes the block inside this transaction.
Constructor Details
#initialize(connection) ⇒ Transaction
Creates a Transaction instance
11 12 13 |
# File 'lib/dbagile/core/transaction.rb', line 11 def initialize(connection) @connection = connection end |
Instance Method Details
#commit ⇒ Object
Commits the transaction
26 27 |
# File 'lib/dbagile/core/transaction.rb', line 26 def commit end |
#execute(&block) ⇒ Object
Executes a block
18 19 20 21 22 23 |
# File 'lib/dbagile/core/transaction.rb', line 18 def execute(&block) raise ArgumentError, "Missing transaction block" unless block connection.chain.transaction do block.call(self) end end |
#rollback ⇒ Object
Rollbacks the transaction
30 31 32 |
# File 'lib/dbagile/core/transaction.rb', line 30 def rollback raise DbAgile::AbordTransactionError end |
#transaction(&block) ⇒ Object
Executes the block inside this transaction
53 54 55 |
# File 'lib/dbagile/core/transaction.rb', line 53 def transaction(&block) execute(&block) end |