rewind_transaction (Transaction::Simple)

    # File lib/transaction/simple.rb, line 187
      def rewind_transaction(name = nil)
        raise Transaction::TransactionError, Transaction::Messages[:cannot_rewind_no_transaction] if @__transaction_checkpoint__.nil?

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

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

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