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
- 
    Enum =
    
 # File 'lib/net/imap/config/attr_type_coercion.rb', line 50->(*enum) { enum = safe{enum} expected = -"one of #{enum.map(&:inspect).join(", ")}" safe{->val { return val if enum.include?(val) raise ArgumentError, "expected %s, got %p" % [expected, val] }} } 
- 
    NilOrInteger =
    
 # File 'lib/net/imap/config/attr_type_coercion.rb', line 48safe{->val { Integer val unless val.nil? }} 
- 
    Types =
    
 # File 'lib/net/imap/config/attr_type_coercion.rb', line 38Hash.new do |h, type| type => Proc | nil; safe{type} end 
Class Method Summary
- .attr_accessor(attr, type: nil)
- .included(mod) private
- 
    
      .safe  
    
    private
    See additional method definition at line 32. 
Class Method Details
.attr_accessor(attr, type: nil)
[ GitHub ]# File 'lib/net/imap/config/attr_type_coercion.rb', line 42
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)
See additional method definition at line 32.
# File 'lib/net/imap/config/attr_type_coercion.rb', line 34
def self.safe(...) Ractor.make_shareable nil.instance_eval(...).freeze end