Skip to content

Commit dcb8f31

Browse files
committed
Add kwarg forwarding to #authenticate [🚧 TODO: split off type kwarg]
1 parent bfe514a commit dcb8f31

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

lib/net/smtp.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
862862
DEFAULT_AUTH_TYPE = :plain
863863

864864
# call-seq:
865+
# authenticate(username, secret, type: DEFAULT_AUTH_TYPE, **, &)
865866
# authenticate(username, secret, type = DEFAULT_AUTH_TYPE, **, &)
866867
#
867868
# Authenticates with the server, using the "AUTH" command.
@@ -871,17 +872,18 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
871872
# All arguments—other than +type+—are forwarded to the authenticator.
872873
# Different authenticators may interpret the +username+ and +secret+
873874
# arguments differently.
874-
def authenticate(user, secret, authtype = DEFAULT_AUTH_TYPE)
875-
check_auth_args authtype, user, secret
875+
def authenticate(user, secret, typearg = nil, type: nil, **kwargs, &block)
876+
authtype = type || typearg || DEFAULT_AUTH_TYPE
877+
check_auth_args(authtype, user, secret, **kwargs)
876878
authenticator = Authenticator.auth_class(authtype).new(self)
877-
critical { authenticator.auth(user, secret) }
879+
critical { authenticator.auth(user, secret, **kwargs) }
878880
end
879881

880882
private
881883

882-
def check_auth_args(type, *args, **kwargs)
883-
return unless type || args.any? || kwargs.any?
884-
type ||= DEFAULT_AUTH_TYPE
884+
def check_auth_args(type_arg = nil, *args, type: nil, **kwargs)
885+
return unless type_arg || type || args.any? || kwargs.any?
886+
type ||= type_arg || DEFAULT_AUTH_TYPE
885887
if (klass = Authenticator.auth_class(type))
886888
klass.check_args(*args, **kwargs)
887889
else

0 commit comments

Comments
 (0)