Module: Net::IMAP::Config::AttrAccessors
- Extended by:
- Forwardable
- Included in:
- Net::IMAP::Config
- Defined in:
- lib/net/imap/config/attr_accessors.rb
Overview
NOTE: This module is an internal implementation detail, with no guarantee of backward compatibility.
attr_accessor values are stored in a struct rather than ivars, making it simpler to ensure that all config objects share a single object shape. This also simplifies iteration over all defined attributes.
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
An array of Config attribute names.
Class Method Summary collapse
-
.attr_accessor(name) ⇒ Object
:nodoc: internal API.
-
.struct ⇒ Object
:nodoc: internal API.
Instance Method Summary collapse
-
#freeze ⇒ Object
Freezes the internal attributes struct, in addition to
self. -
#initialize ⇒ Object
:notnew:.
Instance Attribute Details
#attributes ⇒ Object (readonly)
An array of Config attribute names
36 37 38 |
# File 'lib/net/imap/config/attr_accessors.rb', line 36 def attributes @attributes end |
Class Method Details
.attr_accessor(name) ⇒ Object
:nodoc: internal API
28 29 30 31 32 33 |
# File 'lib/net/imap/config/attr_accessors.rb', line 28 def self.attr_accessor(name) # :nodoc: internal API name = name.to_sym raise ArgumentError, "already defined #{name}" if attributes.include?(name) attributes << name def_delegators :data, name, :"#{name}=" end |
.struct ⇒ Object
:nodoc: internal API
39 40 41 42 |
# File 'lib/net/imap/config/attr_accessors.rb', line 39 def self.struct # :nodoc: internal API attributes.freeze Struct.new(*attributes) end |
Instance Method Details
#freeze ⇒ Object
Freezes the internal attributes struct, in addition to self.
50 51 52 53 |
# File 'lib/net/imap/config/attr_accessors.rb', line 50 def freeze data.freeze super end |
#initialize ⇒ Object
:notnew:
44 45 46 47 |
# File 'lib/net/imap/config/attr_accessors.rb', line 44 def initialize # :notnew: super() @data = Config::Struct.new end |