# File lib/transaction/simple.rb, line 300
  def commit_transaction(name = nil)
    raise Transaction::TransactionError, ___tmessage[:cannot_commit_no_transaction] if @__transaction_checkpoint__.nil?
    @__transaction_block__ ||= nil

    # Check to see if we are trying to commit a transaction that is outside
    # of the current transaction block. Otherwise, raise
    # TransactionCommitted if they are the same.
    if @__transaction_block__ and name
      nix = @__transaction_names__.index(name) + 1
      raise Transaction::TransactionError, ___tmessage[:cannot_commit_transaction_before_block] if nix < @__transaction_block__

      raise Transaction::TransactionCommitted if @__transaction_block__ == nix
    end

    raise Transaction::TransactionCommitted if @__transaction_block__ == @__transaction_level__

    if name.nil?
      ___tdebug "<", "%s(%s)", ___tmessage[:commit_transaction], name.inspect
      __commit_transaction
    else
      raise Transaction::TransactionError, ___tmessage[:cannot_commit_named_transaction] % name.inspect unless @__transaction_names__.include?(name)

      while @__transaction_names__.last != name
        ___tdebug "<", "%s(%s)", ___tmessage[:commit_transaction], name.inspect
        __commit_transaction
        ___tdebug_checkpoint
      end

      ___tdebug "<", "%s(%s)", ___tmessage[:commit_transaction], name.inspect
      __commit_transaction
    end

    ___tdebug_checkpoint

    self
  end