aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-16 15:03:40 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-05-16 15:05:35 -0300
commitd89d859a417ef1baf25819bccdec33e437db3433 (patch)
tree8492ac546fae7417bacd48f5be45214bbd175d00 /activerecord
parent9900703ebf4d2688b2203e9b28d3cc588fac1641 (diff)
downloadrails-d89d859a417ef1baf25819bccdec33e437db3433.tar.gz
rails-d89d859a417ef1baf25819bccdec33e437db3433.tar.bz2
rails-d89d859a417ef1baf25819bccdec33e437db3433.zip
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.
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/transactions.rb13
1 files changed, 8 insertions, 5 deletions
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.