class ActiveRecord::ConnectionAdapters::Transaction

:nodoc:

def add_record(record)

def add_record(record)
  records << record
end

def before_commit_records

def before_commit_records
  records.uniq.each(&:before_committed!) if @run_commit_callbacks
end

def closed?; false; end

def closed?; false; end

def commit_records

def commit_records
  ite = records.uniq(&:__id__)
  already_run_callbacks = {}
  while record = ite.shift
    if @run_commit_callbacks
      trigger_callbacks = record.trigger_transactional_callbacks?
      should_run_callbacks = !already_run_callbacks[record] && trigger_callbacks
      already_run_callbacks[record] ||= trigger_callbacks
      record.committed!(should_run_callbacks: should_run_callbacks)
    else
      # if not running callbacks, only adds the record to the parent transaction
      connection.add_transaction_record(record)
    end
  end
ensure
  ite.each { |i| i.committed!(should_run_callbacks: false) }
end

def full_rollback?; true; end

def full_rollback?; true; end

def initialize(connection, options, run_commit_callbacks: false)

def initialize(connection, options, run_commit_callbacks: false)
  @connection = connection
  @state = TransactionState.new
  @records = []
  @isolation_level = options[:isolation]
  @materialized = false
  @joinable = options.fetch(:joinable, true)
  @run_commit_callbacks = run_commit_callbacks
end

def joinable?; @joinable; end

def joinable?; @joinable; end

def materialize!

def materialize!
  @materialized = true
end

def materialized?

def materialized?
  @materialized
end

def open?; !closed?; end

def open?; !closed?; end

def rollback_records

def rollback_records
  ite = records.uniq(&:__id__)
  already_run_callbacks = {}
  while record = ite.shift
    trigger_callbacks = record.trigger_transactional_callbacks?
    should_run_callbacks = !already_run_callbacks[record] && trigger_callbacks
    already_run_callbacks[record] ||= trigger_callbacks
    record.rolledback!(force_restore_state: full_rollback?, should_run_callbacks: should_run_callbacks)
  end
ensure
  ite.each do |i|
    i.rolledback!(force_restore_state: full_rollback?, should_run_callbacks: false)
  end
end