module Locd::Config::Types

Definitions

Public Class Methods

by_key() click to toggle source

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.

@return [Hamster::Hash]

# File lib/locd/config/types.rb, line 60
def self.by_key
  # Got sick of writing "Hamster::Hash[...]"... "I8" <=> "Immutable"
  @by_key ||= I8[
    'home'  => self.ConfigPath,
    'bin'   => ( t.When( 'locd' ) | self.ConfigPath ),

    'log' => I8[
      'dir' => self.ConfigPath,
    ],

    'tmp' => I8[
      'dir' => self.ConfigPath,
    ],
    
    'cli' => I8[
      'log' => I8[
        'application' => t.non_empty_str,
        'level' => NRSER::Log::Types.level?,
        'dest' => ( NRSER::Log::Types.stdio | self.ConfigPath ),
      ],
      
      'bash_comp' => I8[
        'log' => I8[
          'level' => NRSER::Log::Types.level,
          'dest' => self.ConfigPath,
        ],
      ]
    ]
  ]
end
for_key(*key) click to toggle source

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

@param [Array]

@return [NRSER::Types::Type?]

# File lib/locd/config/types.rb, line 98
def self.for_key *key
  by_key.dig *Locd::Config.key_path_for( *key )
end