Settings
- Class to handle a settings store
use Settings;
# instantiate
my $s=Settings->new();
# load settings into hash
$s->load();
# get a settings value
my $dbname=$s->value("dbname");
# get another one
my $name=$s->value("this.is.a.name.setting");
# get a hash-reference
my $h=$s->value("myhash");
# get a list-reference
my $l=$s->value("mylist");
# reset contents hash, new load is required
$s->reset();
Class to handle a settings store in a easy and quick way to be used by the AURORA-environment.
Instantiates the class.
It takes the following input parameters:
aurorapath Path to where the main aurora-folder resides. SCALAR. Optional. Will default to "/local/app/aurora" if not set, or default to the environment variable AURORA_PATH if that has been set.
path Path to where the config.d folder resides. SCALAR. Optional. Defaults to "/etc/aurora.d" if not set, or if the environment variable AURORA_CONFIG has been set, it will default to that.
container The datacontainer instance to use for storing the settings. It is required to be of type DataContainer. If wrong type or not set, it will default to DataContainer::File using a DataCollection with Content-type Content::YAML.
The return result is the instantiated class.
Resets the settings contents of the Settings instance.
Always returns 1.
Loads settings from multiple config files into the internal HASH.
No input is accepted.
The method will attempt to read configuration settings from files in the following order:
1. /usr/local/lib/aurora/aurora.yaml (default settings template from distribution) 2. /etc/aurora.d or env $AURORA_CONFIG or if "path" is specified to the new()-method, that will be preferred (it will read all files in this folder in alphanumerical order, case-sensitive). Only files that end in ".yaml" will be processed.
Configuration settings from multiple files will be merged into the internal HASH-structure. New settings with the same key-name will overwrite old ones.
It returns 1 upon success, 0 upon failure. Check the error()-method for more information upon failure.
Gets a specific value from the internal HASH or the whole HASH-reference.
It takes one parameter as input and that is the name of the setting to return. If the name is set to blank or undef it will return the whole HASH-structure of the settings (all settings).
It will return undef if the value does not exist.
Checks to see if a given key exists in the loaded settings.
Input is the key-name to check for.
It returns 1 if it exists or 0 if does not or if the key-name was blank.
Returns the last error message from the class.