Class: ActiveRecord::ConnectionAdapters::RealTransaction

Inherits:
Transaction
  • Object
show all
Defined in:
lib/active_record/connection_adapters/abstract/transaction.rb

Overview

Active Record Real Transaction

Instance Attribute Summary

Attributes inherited from Transaction

#connection, #isolation_level, #savepoint_name, #state, #written

Instance Method Summary collapse

Methods inherited from Transaction

#add_record, #before_commit_records, #closed?, #commit_records, #dirty!, #dirty?, #full_rollback?, #incomplete!, #initialize, #joinable?, #materialized?, #open?, #records, #restartable?, #restore!, #rollback_records

Constructor Details

This class inherits a constructor from ActiveRecord::ConnectionAdapters::Transaction

Instance Method Details

#commitObject



392
393
394
395
396
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 392

def commit
  connection.commit_db_transaction if materialized?
  @state.full_commit!
  @instrumenter.finish
end

#materialize!Object



362
363
364
365
366
367
368
369
370
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 362

def materialize!
  if isolation_level
    connection.begin_isolated_db_transaction(isolation_level)
  else
    connection.begin_db_transaction
  end

  super
end

#restartObject



372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 372

def restart
  return unless materialized?

  @instrumenter.finish

  if connection.supports_restart_db_transaction?
    @instrumenter.start
    connection.restart_db_transaction
  else
    connection.rollback_db_transaction
    materialize!
  end
end

#rollbackObject



386
387
388
389
390
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 386

def rollback
  connection.rollback_db_transaction if materialized?
  @state.full_rollback!
  @instrumenter.finish
end