Class: Startback::Support::TransactionManager
- Inherits:
-
Object
- Object
- Startback::Support::TransactionManager
- Defined in:
- lib/startback/support/transaction_manager.rb
Instance Method Summary collapse
- #call(runner, op, &then_block) ⇒ Object
-
#initialize(db, method = :transaction) ⇒ TransactionManager
constructor
A new instance of TransactionManager.
Constructor Details
#initialize(db, method = :transaction) ⇒ TransactionManager
Returns a new instance of TransactionManager.
5 6 7 8 |
# File 'lib/startback/support/transaction_manager.rb', line 5 def initialize(db, method = :transaction) @db = db @method = method end |
Instance Method Details
#call(runner, op, &then_block) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/startback/support/transaction_manager.rb', line 10 def call(runner, op, &then_block) raise ArgumentError, "A block is required" unless then_block before = (op.class.transaction_policy == :before_call) if before @db.send(@method) do then_block.call end else then_block.call end end |