Class: ActiveRecord::ConnectionAdapters::SavepointTransaction

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

Overview

:nodoc:

Instance Attribute Summary

Attributes inherited from OpenTransaction

#joinable, #parent, #records

Attributes inherited from Transaction

#connection

Instance Method Summary collapse

Methods inherited from OpenTransaction

#add_record, #begin, #closed?, #commit, #commit_records, #finishing?, #joinable?, #number, #open?, #rollback, #rollback_records

Methods inherited from Transaction

#state

Constructor Details

#initialize(connection, parent, options = {}) ⇒ SavepointTransaction

Returns a new instance of SavepointTransaction.



182
183
184
185
186
187
188
189
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 182

def initialize(connection, parent, options = {})
  if options[:isolation]
    raise ActiveRecord::TransactionIsolationError, "cannot set transaction isolation in a nested transaction"
  end

  super
  connection.create_savepoint
end

Instance Method Details

#perform_commitObject



196
197
198
199
200
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 196

def perform_commit
  @state.set_state(:committed)
  @state.parent = parent.state
  connection.release_savepoint
end

#perform_rollbackObject



191
192
193
194
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 191

def perform_rollback
  connection.rollback_to_savepoint
  rollback_records
end