Skip to content

Commit

Permalink
Reimplement #authenticate using #auth
Browse files Browse the repository at this point in the history
IMO, the method signature for `#authenticate` is confusing and it the
method should be deprecated in favor of `#auth`.
  • Loading branch information
nevans committed Oct 14, 2023
1 parent b8bbd3c commit d548550
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions lib/net/smtp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -896,18 +896,15 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
# All arguments—other than +type+—are forwarded to the authenticator.
# Different authenticators may interpret the +username+ and +secret+
# arguments differently.
def authenticate(*args, type: nil, **kwargs, &block)
def authenticate(*args, **kwargs, &block)
case args.length
when 1, 3 then typearg = args.pop
when (4..)
raise ArgumentError, "wrong number of arguments " \
"(given %d, expected 0..3)" % [args.length]
end
authtype = type || typearg || DEFAULT_AUTH_TYPE
check_auth_method authtype
check_auth_args(*args) unless args.empty?
authenticator = Authenticator.auth_class(authtype).new(self)
critical { authenticator.auth(*args, **kwargs) }
auth(typearg, *args, **kwargs, &block)
end

# call-seq:
Expand Down

0 comments on commit d548550

Please sign in to comment.