1
1
# frozen_string_literal: true
2
2
3
+ require "forwardable"
4
+
3
5
module Net
4
6
class IMAP
5
7
module SASL
@@ -23,6 +25,8 @@ module SASL
23
25
# possible, ClientAdapter delegates the handling of these requirements to
24
26
# SASL::ProtocolAdapters.
25
27
class ClientAdapter
28
+ extend Forwardable
29
+
26
30
include ProtocolAdapters ::Generic
27
31
28
32
# The client that handles communication with the protocol server.
@@ -59,11 +63,17 @@ def initialize(client, &command_proc)
59
63
# AuthenticationExchange.authenticate.
60
64
def authenticate ( ...) AuthenticationExchange . authenticate ( self , ...) end
61
65
66
+ ##
67
+ # method: sasl_ir_capable?
62
68
# Do the protocol, server, and client all support an initial response?
63
- def sasl_ir_capable? ; client . sasl_ir_capable? end
69
+ def_delegator : client, : sasl_ir_capable?
64
70
71
+ ##
72
+ # method: auth_capable?
73
+ # call-seq: auth_capable?(mechanism)
74
+ #
65
75
# Does the server advertise support for the +mechanism+?
66
- def auth_capable? ( mechanism ) ; client . auth_capable? ( mechanism ) end
76
+ def_delegator : client, : auth_capable?
67
77
68
78
# Calls command_proc with +command_name+ (see
69
79
# SASL::ProtocolAdapters::Generic#command_name),
@@ -83,21 +93,29 @@ def run_command(mechanism, initial_response = nil, &continuations_handler)
83
93
command_proc . call ( *args , &continuations_handler )
84
94
end
85
95
96
+ ##
97
+ # method: host
86
98
# The hostname to which the client connected.
87
- def host ; client . host end
99
+ def_delegator : client, :host
88
100
101
+ ##
102
+ # method: port
89
103
# The destination port to which the client connected.
90
- def port ; client . port end
104
+ def_delegator : client, :port
91
105
92
106
# Returns an array of server responses errors raised by run_command.
93
107
# Exceptions in this array won't drop the connection.
94
108
def response_errors ; [ ] end
95
109
110
+ ##
111
+ # method: drop_connection
96
112
# Drop the connection gracefully, sending a "LOGOUT" command as needed.
97
- def drop_connection ; client . drop_connection end
113
+ def_delegator : client, :drop_connection
98
114
115
+ ##
116
+ # method: drop_connection!
99
117
# Drop the connection abruptly, closing the socket without logging out.
100
- def drop_connection! ; client . drop_connection! end
118
+ def_delegator : client, : drop_connection!
101
119
102
120
end
103
121
end
0 commit comments