11# frozen_string_literal: true
2- # :markup: markdown
32
43require_relative "config/attr_accessors"
54require_relative "config/attr_inheritance"
@@ -11,26 +10,52 @@ class IMAP
1110 # Net::IMAP::Config stores configuration options for Net::IMAP clients.
1211 # The global configuration can be seen at either Net::IMAP.config or
1312 # Net::IMAP::Config.global, and the client-specific configuration can be
14- # seen at Net::IMAP#config. When creating a new client, all unhandled
15- # keyword arguments to Net::IMAP.new are delegated to Config.new. Every
16- # client has its own config.
13+ # seen at Net::IMAP#config.
1714 #
18- # ## Inheritance
15+ # When creating a new client, all unhandled keyword arguments to
16+ # Net::IMAP.new are delegated to Config.new. Every client has its own
17+ # config.
18+ #
19+ # debug_client = Net::IMAP.new(hostname, debug: true)
20+ # quiet_client = Net::IMAP.new(hostname, debug: false)
21+ # debug_client.config.debug? # => true
22+ # quiet_client.config.debug? # => false
23+ #
24+ # == Inheritance
1925 #
2026 # Configs have a parent[rdoc-ref:Config::AttrInheritance#parent] config, and
2127 # any attributes which have not been set locally will inherit the parent's
2228 # value. Every client creates its own specific config. By default, client
23- # configs inherit from Config.global which inherits from Config.default.
29+ # configs inherit from Config.global.
30+ #
31+ # plain_client = Net::IMAP.new(hostname)
32+ # debug_client = Net::IMAP.new(hostname, debug: true)
33+ # quiet_client = Net::IMAP.new(hostname, debug: false)
34+ #
35+ # plain_client.config.inherited?(:debug) # => true
36+ # debug_client.config.inherited?(:debug) # => false
37+ # quiet_client.config.inherited?(:debug) # => false
38+ #
39+ # plain_client.config.debug? # => false
40+ # debug_client.config.debug? # => true
41+ # quiet_client.config.debug? # => false
42+ #
43+ # # Net::IMAP.debug is delegated to Net::IMAP::Config.global.debug
44+ # Net::IMAP.debug = true
45+ # plain_client.config.debug? # => true
46+ # debug_client.config.debug? # => true
47+ # quiet_client.config.debug? # => false
48+ #
49+ # Net::IMAP.debug = false
50+ # plain_client.config.debug = true
51+ # plain_client.config.inherited?(:debug) # => false
52+ # plain_client.config.debug? # => true
53+ # plain_client.config.reset(:debug)
54+ # plain_client.config.inherited?(:debug) # => true
55+ # plain_client.config.debug? # => false
2456 #
25- # See the following methods, defined by Config::AttrInheritance:
26- # - {#new}[rdoc-ref:Config::AttrInheritance#reset] -- create a new config
27- # which inherits from the receiver.
28- # - {#inherited?}[rdoc-ref:Config::AttrInheritance#inherited?] -- return
29- # whether a particular attribute is inherited.
30- # - {#reset}[rdoc-ref:Config::AttrInheritance#reset] -- reset attributes to
31- # be inherited.
3257 #
33- # ## Thread Safety
58+ # == Thread Safety
3459 #
3560 # *NOTE:* Updates to config objects are not synchronized for thread-safety.
3661 #
0 commit comments