Class: ActiveRecord::ConnectionAdapters::RealTransaction

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?, #full_rollback?, #initialize, #joinable?, #materialized?, #open?, #records, #restartable?, #restore!, #rollback_records

Constructor Details

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

Instance Method Details

#commitObject



348
349
350
351
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 348

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

#materialize!Object



322
323
324
325
326
327
328
329
330
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 322

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

  super
end

#restartObject



332
333
334
335
336
337
338
339
340
341
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 332

def restart
  return unless materialized?

  if connection.supports_restart_db_transaction?
    connection.restart_db_transaction
  else
    connection.rollback_db_transaction
    materialize!
  end
end

#rollbackObject



343
344
345
346
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 343

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