Module: Locd::Config::Types

Extended by:
tt::Factory
Defined in:
lib/locd/config/types.rb

Overview

Definitions

Class Method Summary collapse

Class Method Details

.by_keyHamster::Hash

A tree representing config key paths to the types they need to be.

Computed on first call and cached after that as it needs the type factories below.

Returns:

  • (Hamster::Hash)


60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/locd/config/types.rb', line 60

def self.by_key
  # Got sick of writing "Hamster::Hash[...]"... "I8" <=> "Immutable"
  @by_key ||= I8[
    'home'  => config_path,
    'bin'   => ( t.when( 'locd' ) | config_path ),
    
    'cli' => I8[
      'log' => I8[
        'application' => t.non_empty_str,
        'level' => NRSER::Log::Types.level?,
        'dest' => ( NRSER::Log::Types.stdio | config_path ),
      ],
      
      'bash_comp' => I8[
        'log' => I8[
          'level' => NRSER::Log::Types.level,
          'dest' => config_path,
        ],
      ]
    ]
  ]
end

.for_key(*key) ⇒ NRSER::Types::Type?

Dig in to BY_KEY and see if it has a type for a key.

Parameters:

  • (Array)

Returns:

  • (NRSER::Types::Type?)


90
91
92
# File 'lib/locd/config/types.rb', line 90

def self.for_key *key
  by_key.dig *Locd::Config.key_path_for( *key )
end