From 7be2a37bc9eeaf23eed172677e99562535d94cfa Mon Sep 17 00:00:00 2001
From: Ryuta Kamizono <kamipo@gmail.com>
Date: Sun, 14 Apr 2019 21:53:22 +0900
Subject: Remove useless `update_attributes_from_transaction_state` and
 `set_transaction_state`

---
 activerecord/lib/active_record/transactions.rb | 17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)

(limited to 'activerecord/lib')

diff --git a/activerecord/lib/active_record/transactions.rb b/activerecord/lib/active_record/transactions.rb
index 00a62a70d6..ffbcf1f8b2 100644
--- a/activerecord/lib/active_record/transactions.rb
+++ b/activerecord/lib/active_record/transactions.rb
@@ -366,7 +366,7 @@ module ActiveRecord
       self.class.transaction do
         unless has_transactional_callbacks?
           sync_with_transaction_state
-          set_transaction_state(self.class.connection.transaction_state)
+          @transaction_state = self.class.connection.transaction_state
         end
         remember_transaction_record_state
 
@@ -382,7 +382,8 @@ module ActiveRecord
     end
 
     private
-      attr_reader :_committed_already_called, :_trigger_update_callback, :_trigger_destroy_callback
+      attr_reader :_committed_already_called, :_trigger_update_callback, :_trigger_destroy_callback,
+        :transaction_state
 
       # Save the new record state and id of a record so it can be restored later if a transaction fails.
       def remember_transaction_record_state
@@ -453,10 +454,6 @@ module ActiveRecord
         self.class.connection.add_transaction_record(self)
       end
 
-      def set_transaction_state(state)
-        @transaction_state = state
-      end
-
       def has_transactional_callbacks?
         !_rollback_callbacks.empty? || !_commit_callbacks.empty? || !_before_commit_callbacks.empty?
       end
@@ -474,15 +471,7 @@ module ActiveRecord
       # This method checks to see if the ActiveRecord object's state reflects
       # the TransactionState, and rolls back or commits the Active Record object
       # as appropriate.
-      #
-      # Since Active Record objects can be inside multiple transactions, this
-      # method recursively goes through the parent of the TransactionState and
-      # checks if the Active Record object reflects the state of the object.
       def sync_with_transaction_state
-        update_attributes_from_transaction_state(@transaction_state)
-      end
-
-      def update_attributes_from_transaction_state(transaction_state)
         if transaction_state && transaction_state.finalized?
           restore_transaction_record_state(transaction_state.fully_rolledback?) if transaction_state.rolledback?
           force_clear_transaction_record_state if transaction_state.fully_committed?
-- 
cgit v1.2.3