Module: WithDisposableTransactionExtension
- Defined in:
- lib/prefactory/active_record_integration.rb
Instance Method Summary collapse
-
#with_disposable_transaction(&block) ⇒ Object
do a transaction with a silent rollback (unless another exception is doing a loud rollback already) and trigger commit logic for any transaction above this open-transaction level.
Instance Method Details
#with_disposable_transaction(&block) ⇒ Object
do a transaction with a silent rollback (unless another exception is doing a loud rollback already) and trigger commit logic for any transaction above this open-transaction level.
123 124 125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/prefactory/active_record_integration.rb', line 123 def with_disposable_transaction(&block) return_value = nil ActiveRecord::Base.connection.transaction(:requires_new => true) do ActiveRecord::Base.connection.commit_at_open_transaction_level = ActiveRecord::Base.connection.open_transactions begin return_value = yield rescue StandardError => e raise e end raise ActiveRecord::Rollback end return_value end |