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.



186
187
188
189
190
191
192
193
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 186

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



200
201
202
203
204
205
# File 'activerecord/lib/active_record/connection_adapters/abstract/transaction.rb', line 200

def perform_commit
  @state.set_state(:committed)
  @state.parent = parent.state
  connection.release_savepoint
  records.each { |r| parent.add_record(r) }
end

#perform_rollbackObject



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

def perform_rollback
  connection.rollback_to_savepoint
  rollback_records
end