From d89d859a417ef1baf25819bccdec33e437db3433 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafael=20Mendon=C3=A7a=20Fran=C3=A7a?= Date: Fri, 16 May 2014 15:03:40 -0300 Subject: Add a specific method to force the transaction record state clear We are using that code path in only one place so we should not add a conditional to all the other cases. This will avoid performance regressions on the old paths. --- activerecord/lib/active_record/transactions.rb | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'activerecord/lib/active_record/transactions.rb') diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 51bda88be9..0c26fb3b1a 100644 --- a/activerecord/lib/active_record/transactions.rb +++ b/activerecord/lib/active_record/transactions.rb @@ -295,7 +295,7 @@ module ActiveRecord def committed! #:nodoc: run_callbacks :commit if destroyed? || persisted? ensure - clear_transaction_record_state(true) + force_clear_transaction_record_state end # Call the +after_rollback+ callbacks. The +force_restore_state+ argument indicates if the record @@ -353,11 +353,14 @@ module ActiveRecord end # Clear the new record state and id of a record. - def clear_transaction_record_state(force = false) #:nodoc: + def clear_transaction_record_state #:nodoc: @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1 - if force || @_start_transaction_state[:level] < 1 - @_start_transaction_state.clear - end + @_start_transaction_state.clear @_start_transaction_state[:level] < 1 + end + + # Force to clear the teansaction record state. + def force_clear_transaction_record_state #:nodoc: + @_start_transaction_state.clear end # Restore the new record state and id of a record that was previously saved by a call to save_record_state. -- cgit v1.2.3