Class: ActiveRecord::ConnectionAdapters::RestartParentTransaction

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

Overview

Active Record Restart Parent 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?, #incomplete!, #joinable?, #materialize!, #materialized?, #open?, #records, #restartable?, #restore!, #rollback_records

Constructor Details

#initialize(connection, parent_transaction, **options) ⇒ RestartParentTransaction

Returns a new instance of RestartParentTransaction.



377
378
379
380
381
382
383
384
385
386
387
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 377

def initialize(connection, parent_transaction, **options)
  super(connection, **options)

  @parent = parent_transaction

  if isolation_level
    raise ActiveRecord::TransactionIsolationError, "cannot set transaction isolation in a nested transaction"
  end

  @parent.state.add_child(@state)
end

Instance Method Details

#commitObject



396
397
398
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 396

def commit
  @state.commit!
end

#full_rollback?Boolean

Returns:

  • (Boolean)


400
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 400

def full_rollback?; false; end

#rollbackObject



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

def rollback
  @state.rollback!
  @parent.restart
end