module WithDisposableTransactionExtension
Public Instance Methods
with_disposable_transaction() { || ... }
click to toggle source
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.
# 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