Method: ActiveRecord::ConnectionAdapters::DatabaseStatements#reset_transaction
- Defined in:
- activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb
#reset_transaction(restore: false) ⇒ Object
:nodoc:
385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 |
# File 'activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb', line 385 def reset_transaction(restore: false) # :nodoc: # Store the existing transaction state to the side old_state = @transaction_manager if restore && @transaction_manager&.restorable? @transaction_manager = ConnectionAdapters::TransactionManager.new(self) if block_given? # Reconfigure the connection without any transaction state in the way result = yield # Now the connection's fully established, we can swap back if old_state @transaction_manager = old_state @transaction_manager.restore_transactions end result end end |