123456789_123456789_123456789_123456789_123456789_

Module: Net::IMAP::Config::AttrTypeCoercion

Do not use. This module is for internal use only.
Relationships & Source Files
Namespace Children
Modules:
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/net/imap/config/attr_type_coercion.rb

Overview

NOTE: This module is an internal implementation detail, with no guarantee of backward compatibility.

Adds a type keyword parameter to .attr_accessor, to enforce that config attributes have valid types, for example: boolean, numeric, enumeration, non-nullable, etc.

Constant Summary

Class Method Summary

Class Method Details

.attr_accessor(attr, type: nil)

[ GitHub ]

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

def self.attr_accessor(attr, type: nil)
  type = Types[type] or return
  define_method :"#{attr}=" do |val| super type[val] end
  define_method :"#{attr}?" do send attr end if type == Boolean
end

.included(mod) (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_type_coercion.rb', line 26

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

.safe (private)

[ GitHub ]

  
# File 'lib/net/imap/config/attr_type_coercion.rb', line 31

def self.safe(...) = Ractor.make_shareable nil.instance_eval(...).freeze