diff options
author | Arthur Neves <arthurnn@gmail.com> | 2014-05-15 13:56:44 -0400 |
---|---|---|
committer | Arthur Neves <arthurnn@gmail.com> | 2014-05-15 16:29:16 -0400 |
commit | e3d223bcce28c3ac70b84399f9b211ae11542233 (patch) | |
tree | 673871c809f7830243614e3c223a999a9ea15cb5 /activerecord | |
parent | 16a8a68b7eb71e57fc457750758d2dc8e978584b (diff) | |
download | rails-e3d223bcce28c3ac70b84399f9b211ae11542233.tar.gz rails-e3d223bcce28c3ac70b84399f9b211ae11542233.tar.bz2 rails-e3d223bcce28c3ac70b84399f9b211ae11542233.zip |
Small refactoring on clear_transaction_record_state
Make sure when we clean the `@_start_transaction_state` var we do it in
the same code-path.
Also this makes `clear_transaction_record_state`, more consistent with `restore_transaction_record_state`
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/transactions.rb | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb index 17f76b63b3..c0d8b8ddd4 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 - @_start_transaction_state.clear + clear_transaction_record_state(true) end # Call the +after_rollback+ callbacks. The +force_restore_state+ argument indicates if the record @@ -353,9 +353,11 @@ module ActiveRecord end # Clear the new record state and id of a record. - def clear_transaction_record_state #:nodoc: + def clear_transaction_record_state(force = false) #:nodoc: @_start_transaction_state[:level] = (@_start_transaction_state[:level] || 0) - 1 - @_start_transaction_state.clear if @_start_transaction_state[:level] < 1 + if force || @_start_transaction_state[:level] < 1 + @_start_transaction_state.clear + end end # Restore the new record state and id of a record that was previously saved by a call to save_record_state. |