Class: ActiveRecord::ConnectionAdapters::SavepointTransaction

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

Instance Attribute Summary

Attributes inherited from Transaction

#connection, #joinable, #records, #savepoint_name, #state

Instance Method Summary collapse

Methods inherited from Transaction

#add_record, #before_commit_records, #closed?, #commit_records, #joinable?, #open?, #rollback_records

Constructor Details

#initialize(connection, savepoint_name, parent_transaction, options, *args) ⇒ SavepointTransaction

Returns a new instance of SavepointTransaction.



145
146
147
148
149
150
151
152
153
154
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 145

def initialize(connection, savepoint_name, parent_transaction, options, *args)
  super(connection, options, *args)

  parent_transaction.state.add_child(@state)

  if options[:isolation]
    raise ActiveRecord::TransactionIsolationError, "cannot set transaction isolation in a nested transaction"
  end
  connection.create_savepoint(@savepoint_name = savepoint_name)
end

Instance Method Details

#commitObject



161
162
163
164
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 161

def commit
  connection.release_savepoint(savepoint_name)
  @state.commit!
end

#full_rollback?Boolean

Returns:

  • (Boolean)


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

def full_rollback?; false; end

#rollbackObject



156
157
158
159
# File 'lib/active_record/connection_adapters/abstract/transaction.rb', line 156

def rollback
  connection.rollback_to_savepoint(savepoint_name)
  @state.rollback!
end