Class: Aloe::TransactionRollback
- Inherits:
-
Struct
- Object
- Struct
- Aloe::TransactionRollback
- Defined in:
- lib/aloe/transaction_rollback.rb
Overview
Use case class for rolling back a transaction.
Instance Attribute Summary collapse
-
#transaction ⇒ Object
Returns the value of attribute transaction.
Instance Method Summary collapse
Instance Attribute Details
#transaction ⇒ Object
Returns the value of attribute transaction
3 4 5 |
# File 'lib/aloe/transaction_rollback.rb', line 3 def transaction @transaction end |
Instance Method Details
#rollback! ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/aloe/transaction_rollback.rb', line 5 def rollback! ActiveRecord::Base.transaction do e1 = credit_entry.account.create_entry debit_entry.amount.cents e2 = debit_entry.account.create_entry credit_entry.amount.cents rollback = Aloe::Transaction.create! credit_entry: e2, debit_entry: e1, category: Aloe::ROLLBACK_TRANSACTION transaction.update_attribute :adjustment_transaction, rollback end end |