@@ -879,12 +879,14 @@ def open_message_stream(from_addr, *to_addrs, &block) # :yield: stream
879
879
DEFAULT_AUTH_TYPE = :plain
880
880
881
881
# call-seq:
882
- # authenticate(authtype = DEFAULT_AUTH_TYPE, **, &)
883
- # authenticate(username, secret, authtype = DEFAULT_AUTH_TYPE, **, &)
882
+ # authenticate(type: DEFAULT_AUTH_TYPE, **, &)
883
+ # authenticate(type = DEFAULT_AUTH_TYPE, **, &)
884
+ # authenticate(username, secret, type: DEFAULT_AUTH_TYPE, **, &)
885
+ # authenticate(username, secret, type = DEFAULT_AUTH_TYPE, **, &)
884
886
#
885
887
# Authenticates with the server, using the "AUTH" command.
886
888
#
887
- # +authtype + is the name of a SASL authentication mechanism.
889
+ # +type + is the name of a SASL authentication mechanism.
888
890
#
889
891
# All arguments—other than +authtype+—are forwarded to the authenticator.
890
892
# Different authenticators may interpret the +username+ and +secret+
@@ -896,19 +898,19 @@ def authenticate(*args, **kwargs, &block)
896
898
raise ArgumentError , "wrong number of arguments " \
897
899
"(given %d, expected 0..3)" % [ args . length ]
898
900
end
899
- authtype ||= DEFAULT_AUTH_TYPE
900
- check_auth_args authtype , *args , **kwargs
901
+ authtype , args , kwargs = check_auth_args authtype , *args , **kwargs
901
902
authenticator = Authenticator . auth_class ( authtype ) . new ( self )
902
903
authenticator . auth ( *args , **kwargs , &block )
903
904
end
904
905
905
906
private
906
907
907
- def check_auth_args ( type , *args , **kwargs )
908
- type ||= DEFAULT_AUTH_TYPE
908
+ def check_auth_args ( type_arg = nil , *args , type : nil , **kwargs )
909
+ type ||= type_arg || DEFAULT_AUTH_TYPE
909
910
klass = Authenticator . auth_class ( type ) or
910
911
raise ArgumentError , "wrong authentication type #{ type } "
911
912
klass . check_args ( *args , **kwargs )
913
+ [ type , args , kwargs ]
912
914
end
913
915
914
916
#
0 commit comments