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, #user_transaction, #written

Instance Method Summary collapse

Methods inherited from Transaction

#add_record, #after_commit, #after_rollback, #before_commit, #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



480
481
482
483
484
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 480

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

#materialize!Object



450
451
452
453
454
455
456
457
458
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 450

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

  super
end

#restartObject



460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 460

def restart
  return unless materialized?

  @instrumenter.finish(:restart)

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

#rollbackObject



474
475
476
477
478
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 474

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