Class: Snapback::Transaction
- Inherits:
-
Object
- Object
- Snapback::Transaction
- Defined in:
- lib/snapback/transaction.rb
Instance Method Summary collapse
-
#initialize(&block) ⇒ Transaction
constructor
A new instance of Transaction.
- #revert(&block) ⇒ Object
- #rollback ⇒ Object
Constructor Details
#initialize(&block) ⇒ Transaction
Returns a new instance of Transaction.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/snapback/transaction.rb', line 4 def initialize(&block) @reverts = [] begin instance_eval &block rescue Exception => msg rollback raise msg # re-throw end end |
Instance Method Details
#revert(&block) ⇒ Object
15 16 17 |
# File 'lib/snapback/transaction.rb', line 15 def revert(&block) @reverts.push block end |