# File lib/transaction/simple.rb, line 376
376:     def rewind_transaction(name = nil)
377:       if @__transaction_checkpoint__.nil?
378:         raise TransactionError, Messages[:cannot_rewind_no_transaction]
379:       end
380: 
381:         # Check to see if we are trying to rewind a transaction that is
382:         # outside of the current transaction block.
383:       if @__transaction_block__ and name
384:         nix = @__transaction_names__.index(name) + 1
385:         if nix < @__transaction_block__
386:           raise TransactionError, Messages[:cannot_rewind_transaction_before_block]
387:         end
388:       end
389: 
390:       if name.nil?
391:         __rewind_this_transaction
392:         ss = "" if Transaction::Simple.debugging?
393:       else
394:         unless @__transaction_names__.include?(name)
395:           raise TransactionError, Messages[:cannot_rewind_named_transaction] % name.inspect
396:         end
397:         ss = "(#{name})" if Transaction::Simple.debugging?
398: 
399:         while @__transaction_names__[-1] != name
400:           @__transaction_checkpoint__ = __rewind_this_transaction
401:           if Transaction::Simple.debugging?
402:             Transaction::Simple.debug_io << "#{'|' * @__transaction_level__} " <<
403:               "Rewind Transaction#{ss}\n"
404:           end
405:           @__transaction_level__ -= 1
406:           @__transaction_names__.pop
407:         end
408:         __rewind_this_transaction
409:       end
410:       if Transaction::Simple.debugging?
411:         Transaction::Simple.debug_io << "#{'|' * @__transaction_level__} " <<
412:           "Rewind Transaction#{ss}\n"
413:       end
414:       self
415:     end