Module: ActiveRecord::Transactions

Defined in:
ext/active_record/transactions.rb

Overview

See ActiveRecord::Transactions::ClassMethods for documentation.

Instance Method Summary collapse

Instance Method Details

#save!Object

# See ActiveRecord::Transactions::ClassMethods for detailed documentation. def transaction(options = {}, &block)

self.class.transaction(options, &block)

end

def destroy #:nodoc:

with_transaction_returning_status { super }

end

def save(*) #:nodoc:

rollback_active_record_state! do
  with_transaction_returning_status { super }
end

end



23
24
25
26
27
28
29
# File 'ext/active_record/transactions.rb', line 23

def save!(**) #:nodoc:
  if instance_variable_defined?(:@no_save_transaction) && @no_save_transaction
    super
  else
    with_transaction_returning_status { super }
  end
end

#with_transaction_returning_statusObject

def touch(*) #:nodoc:

with_transaction_returning_status { super }

end



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'ext/active_record/transactions.rb', line 36

def with_transaction_returning_status
  self.class.with_connection do |connection|
    status = nil
    # connection = self.class.connection

    if connection.is_a?(ActiveRecord::ConnectionAdapters::SunstoneAPIAdapter) && instance_variable_defined?(:@sunstone_updating) && @sunstone_updating
      status = yield
    else
      ensure_finalize = !connection.transaction_open?
      connection.transaction do
        add_to_transaction(ensure_finalize || has_transactional_callbacks?)
        remember_transaction_record_state

        status = yield
        raise ActiveRecord::Rollback unless status
      end
    end
  
    status
  end
end