# File lib/transaction/simple.rb, line 462
462:     def commit_transaction(name = nil)
463:       if @__transaction_checkpoint__.nil?
464:         raise TransactionError, Messages[:cannot_commit_no_transaction]
465:       end
466:       @__transaction_block__ ||= nil
467: 
468:         # Check to see if we are trying to commit a transaction that is
469:         # outside of the current transaction block. Otherwise, raise
470:         # TransactionCommitted if they are the same.
471:       if @__transaction_block__ and name
472:         nix = @__transaction_names__.index(name) + 1
473:         if nix < @__transaction_block__
474:           raise TransactionError, Messages[:cannot_commit_transaction_before_block]
475:         end
476: 
477:         raise TransactionCommitted if @__transaction_block__ == nix
478:       end
479: 
480:       raise TransactionCommitted if @__transaction_block__ == @__transaction_level__
481: 
482:       if name.nil?
483:         ss = "" if Transaction::Simple.debugging?
484:         __commit_transaction
485:         if Transaction::Simple.debugging?
486:           Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
487:             "Commit Transaction#{ss}\n"
488:         end
489:       else
490:         unless @__transaction_names__.include?(name)
491:           raise TransactionError, Messages[:cannot_commit_named_transaction] % name.inspect
492:         end
493:         ss = "(#{name})" if Transaction::Simple.debugging?
494: 
495:         while @__transaction_names__[-1] != name
496:           if Transaction::Simple.debugging?
497:             Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
498:               "Commit Transaction#{ss}\n"
499:           end
500:           __commit_transaction
501:         end
502:         if Transaction::Simple.debugging?
503:           Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
504:             "Commit Transaction#{ss}\n"
505:         end
506:         __commit_transaction
507:       end
508: 
509:       self
510:     end