    # File lib/active_record/vendor/simple.rb, line 376
        def rewind_transaction(name = nil)
          if @__transaction_checkpoint__.nil?
            raise TransactionError, Messages[:cannot_rewind_no_transaction]
          end

            # Check to see if we are trying to rewind a transaction that is
            # outside of the current transaction block.
          if @__transaction_block__ and name
            nix = @__transaction_names__.index(name) + 1
            if nix < @__transaction_block__
              raise TransactionError, Messages[:cannot_rewind_transaction_before_block]
            end
          end

          if name.nil?
            __rewind_this_transaction
            ss = "" if Transaction::Simple.debugging?
          else
            unless @__transaction_names__.include?(name)
              raise TransactionError, Messages[:cannot_rewind_named_transaction] % name.inspect
            end
            ss = "(#{name})" if Transaction::Simple.debugging?

            while @__transaction_names__[-1] != name
              @__transaction_checkpoint__ = __rewind_this_transaction
              if Transaction::Simple.debugging?
                Transaction::Simple.debug_io << "#{'|' * @__transaction_level__} " <<
                  "Rewind Transaction#{ss}\n"
              end
              @__transaction_level__ -= 1
              @__transaction_names__.pop
            end
            __rewind_this_transaction
          end
          if Transaction::Simple.debugging?
            Transaction::Simple.debug_io << "#{'|' * @__transaction_level__} " <<
              "Rewind Transaction#{ss}\n"
          end
          self
        end