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


284
285
286
287
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 284

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

#materialize!Object


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

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

  super
end

#restartObject


268
269
270
271
272
273
274
275
276
277
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 268

def restart
  return unless materialized?

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

#rollbackObject


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

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