1
1
# frozen_string_literal: true
2
- # :markup: markdown
3
2
4
3
require_relative "config/attr_accessors"
5
4
require_relative "config/attr_inheritance"
@@ -11,26 +10,52 @@ class IMAP
11
10
# Net::IMAP::Config stores configuration options for Net::IMAP clients.
12
11
# The global configuration can be seen at either Net::IMAP.config or
13
12
# 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.
17
14
#
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
19
25
#
20
26
# Configs have a parent[rdoc-ref:Config::AttrInheritance#parent] config, and
21
27
# any attributes which have not been set locally will inherit the parent's
22
28
# 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
24
56
#
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.
32
57
#
33
- # ## Thread Safety
58
+ # == Thread Safety
34
59
#
35
60
# *NOTE:* Updates to config objects are not synchronized for thread-safety.
36
61
#
0 commit comments