123456789_123456789_123456789_123456789_123456789_

Module: Net::IMAP::Config::AttrAccessors

Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, Forwardable
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.

Class Method Summary

Instance Attribute Summary

  • #data readonly protected Internal use only

    internal API.

Instance Method Summary

Class Method Details

.attr_accessor(name)

This method is for internal use only.

internal API

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 28

def self.attr_accessor(name) # :nodoc: internal API
  name = name.to_sym
  def_delegators :data, name, :"#{name}="
end

.attributes (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 33

def self.attributes
  instance_methods.grep(/=\z/).map { _1.to_s.delete_suffix("=").to_sym }
end

.included(mod) (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 21

def self.included(mod)
  mod.extend Macros
end

.struct

This method is for internal use only.

internal API

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 38

def self.struct # :nodoc: internal API
  unless defined?(self::Struct)
    const_set :Struct, Struct.new(*attributes)
  end
  self::Struct
end

Instance Attribute Details

#data (readonly, protected)

This method is for internal use only.

internal API

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 58

attr_reader :data # :nodoc: internal API

Instance Method Details

#freeze

Freezes the internal attributes struct, in addition to self.

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 51

def freeze
  data.freeze
  super
end

#initialize

:notnew:

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 45

def initialize # :notnew:
  super()
  @data = AttrAccessors.struct.new
end

#initialize_clone(other) (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 62

def initialize_clone(other)
  super
  @data = other.data.clone
end

#initialize_dup(other) (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_accessors.rb', line 67

def initialize_dup(other)
  super
  @data = other.data.dup
end