Module: ActiveRecord::Transactions

Defined in:
lib/active_record/transactions.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods Classes: TransactionError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/active_record/transactions.rb', line 10

def self.included(base)
  base.extend(ClassMethods)

  base.class_eval do
    [:destroy, :save, :save!].each do |method|
      alias_method_chain method, :transactions
    end
  end
end

Instance Method Details

#destroy_with_transactionsObject

:nodoc:



124
125
126
# File 'lib/active_record/transactions.rb', line 124

def destroy_with_transactions #:nodoc:
  transaction { destroy_without_transactions }
end

#save_with_transactions(perform_validation = true) ⇒ Object

:nodoc:



128
129
130
# File 'lib/active_record/transactions.rb', line 128

def save_with_transactions(perform_validation = true) #:nodoc:
  transaction { save_without_transactions(perform_validation) }
end

#save_with_transactions!Object

:nodoc:



132
133
134
# File 'lib/active_record/transactions.rb', line 132

def save_with_transactions! #:nodoc:
  transaction { save_without_transactions! }
end

#transaction(*objects, &block) ⇒ Object



120
121
122
# File 'lib/active_record/transactions.rb', line 120

def transaction(*objects, &block)
  self.class.transaction(*objects, &block)
end