@@ -769,6 +769,11 @@ class << self
769
769
# Returns the initial greeting the server, an UntaggedResponse.
770
770
attr_reader :greeting
771
771
772
+ # The client configuration. See Net::IMAP::Config.
773
+ #
774
+ # By default, config inherits from the global Net::IMAP.config.
775
+ attr_reader :config
776
+
772
777
# Seconds to wait until a connection is opened.
773
778
# If the IMAP object cannot open a connection within this time,
774
779
# it raises a Net::OpenTimeout exception. The default value is 30 seconds.
@@ -816,11 +821,20 @@ class << self
816
821
# the keys are names of attribute assignment methods on
817
822
# SSLContext[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html].
818
823
#
824
+ # [config]
825
+ # A Net::IMAP::Config object to base the client #config on. By default
826
+ # the global Net::IMAP.config is used. Note that this sets the _parent_
827
+ # config object for inheritance. Every Net::IMAP client has its own
828
+ # unique #config for overrides.
829
+ #
819
830
# [open_timeout]
820
831
# Seconds to wait until a connection is opened
821
832
# [idle_response_timeout]
822
833
# Seconds to wait until an IDLE response is received
823
834
#
835
+ # Any other keyword arguments will be forwarded to Config.new, to create the
836
+ # client's #config.
837
+ #
824
838
# See DeprecatedClientOptions.new for deprecated arguments.
825
839
#
826
840
# ==== Examples
@@ -877,10 +891,12 @@ class << self
877
891
# Connected to the host successfully, but it immediately said goodbye.
878
892
#
879
893
def initialize ( host , port : nil , ssl : nil ,
880
- open_timeout : 30 , idle_response_timeout : 5 )
894
+ open_timeout : 30 , idle_response_timeout : 5 ,
895
+ config : Config . global , **config_options )
881
896
super ( )
882
897
# Config options
883
898
@host = host
899
+ @config = Config . new ( config , **config_options )
884
900
@port = port || ( ssl ? SSL_PORT : PORT )
885
901
@open_timeout = Integer ( open_timeout )
886
902
@idle_response_timeout = Integer ( idle_response_timeout )
@@ -894,7 +910,7 @@ def initialize(host, port: nil, ssl: nil,
894
910
@capabilities = nil
895
911
896
912
# Client Protocol Receiver
897
- @parser = ResponseParser . new
913
+ @parser = ResponseParser . new ( config : @config )
898
914
@responses = Hash . new { |h , k | h [ k ] = [ ] }
899
915
@response_handlers = [ ]
900
916
@receiver_thread = nil
0 commit comments