Config
Last updated
Was this helpful?
Last updated
Was this helpful?
The Scar::Config
module provides an easy way of storing key-value configuration. It uses to save and load the config file.
To use it, you have to declare your configuration structure. To do that, you can use the Scar::Config#define_standards
macro at toplevel. Just provide a hash with names and default values for every config entry. The values have to be of any type in the YAML::Any
union.
There are methods for all sorts of config manipulation. You can..
reset(key)
any value by key to its standard
load_standards
to reset all values
[](key)
to access a value by key (returns the default value if it is not present)
[]=(key, value)
to set a value
save(fname)
to save the current configuration to a file (via #write_file)
load(fname)
to load a configuration from a file (via #read_file)
dump
the yaml representation of the current configuration for debugging.