abstract class Comandante::ConfigSingleton

Overview

Create your config class from this

Example

class Config < ConfigSingleton
  config_type(MyConfig) do
    name : String = "foo"
    age : Int32 = 150
  end
  ...
end

if you intend to use nested types define one or more sub_config_type

sub_config_type(URLConfig) do
  scheme : String = "https"
  no_proxy : Bool = false
end

config_type(ServerConfig) do
  urls : Hash(String, URLConfig) = Hash(String, URLConfig).new
end

Included Modules

Defined in:

comandante/config_singleton.cr

Class Method Summary

Macro Summary

Class Method Detail

def self.load_config(file) #

Used to load/read config file

Example

Config.load_config(ARGV[0])

[View source]
def self.to_yaml #

Dumps to yaml

Example

Config.to_yaml

[View source]

Macro Detail

macro config_type(klass, &block) #

defines a config type and accessors of its properties on the singleton class as well as on @config, also defines a load_config


[View source]
macro sub_config_type(klass, &block) #

test this


[View source]