Class: ActiveRecord::ConnectionAdapters::RestartParentTransaction

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

Instance Attribute Summary

Attributes inherited from Transaction

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

Instance Method Summary collapse

Methods inherited from Transaction

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

Constructor Details

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

Returns a new instance of RestartParentTransaction.



258
259
260
261
262
263
264
265
266
267
268
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 258

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



277
278
279
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 277

def commit
  @state.commit!
end

#full_rollback?Boolean

Returns:

  • (Boolean)


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

def full_rollback?; false; end

#rollbackObject



272
273
274
275
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 272

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