See ActiveRecord::Transactions::ClassMethods for documentation.
Add the record to the current transaction so that the :after_rollback and :after_commit callbacks can be called.
# File lib/active_record/transactions.rb, line 279 def add_to_transaction if self.class.connection.add_transaction_record(self) remember_transaction_record_state end end
Reset id and @new_record if the transaction rolls back.
# File lib/active_record/transactions.rb, line 250 def rollback_active_record_state! remember_transaction_record_state yield rescue Exception IdentityMap.remove(self) if IdentityMap.enabled? restore_transaction_record_state raise ensure clear_transaction_record_state end
See ActiveRecord::Transactions::ClassMethods for detailed documentation.
# File lib/active_record/transactions.rb, line 231 def transaction(options = {}, &block) self.class.transaction(options, &block) end
Executes method within a transaction and captures its return value as a status flag. If the status is true the transaction is committed, otherwise a ROLLBACK is issued. In any case the status flag is returned.
This method is available within the context of an ActiveRecord::Base instance.
# File lib/active_record/transactions.rb, line 291 def with_transaction_returning_status status = nil self.class.transaction do add_to_transaction status = yield raise ActiveRecord::Rollback unless status end status end
Generated with the Darkfish Rdoc Generator 2.