NAME

Settings - Class to handle a settings store

SYNOPSIS

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();

DESCRIPTION

Class to handle a settings store in a easy and quick way to be used by the AURORA-environment.

CONSTRUCTOR

new()

Instantiates the class.

It takes the following input parameters:

The return result is the instantiated class.

METHODS

reset()

Resets the settings contents of the Settings instance.

Always returns 1.

load()

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.

value()

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.

exists()

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.

error()

Returns the last error message from the class.