NAME
Acrux::Config - Config::General Configuration of Acrux
SYNOPSIS
use Acrux::Config;
my $config = Acrux::Config->new(
file => '/etc/myapp.conf',
);
say $config->get('foo');
DESCRIPTION
The module works with the configuration using Config::General
All getters of this class are allows get access to configuration parameters by path-pointers. See Acrux::Pointer and RFC 6901
new
my $config = Acrux::Config->new(
file => '/etc/myapp.conf',
default => {foo => 'bar'},
);
ATTRIBUTES
This plugin supports the following attributes
default
default => {foo => 'bar'}
Default configuration data
dirs
dirs => ['/etc/foo', '/etc/bar']
Paths to additional directories of config files
file
file => '/etc/foo.stuff'
Path to configuration file, absolute or relative, defaults to the value of the $0.conf
in the current directory
noload
noload => 1
This attribute disables loading config file
options
options => {'-AutoTrue' => 0}
Sets the Config::General options directly
root
root => '/etc/myapp'
Sets the root directory to configuration files and directories location
METHODS
This plugin implements the following methods
array, list
dumper $config->array('/foo'); # ['first', 'second', 'third']
# ['first', 'second', 'third']
dumper $config->array('/foo'); # 'value'
# ['value']
Returns an array of found values from configuration
config, conf
my $config_hash = $config->config; # { ... }
This method returns config structure directly as hash ref
error
my $error = $config->error;
Returns error string if occurred any errors while creating the object or reading the configuration file
first
say $config->first('/foo'); # ['first', 'second', 'third']
# first
Returns an first value of found values from configuration
get
say $config->get('/datadir');
Returns configuration value by path
hash, object
dumper $config->hash('/foo'); # { foo => 'first', bar => 'second' }
# { foo => 'first', bar => 'second' }
Returns an hash of found values from configuration
latest
say $config->latest('/foo'); # ['first', 'second', 'third']
# third
Returns an latest value of found values from configuration
load
my $config = $config->load;
Loading config files
pointer
my $pointer = $config->pointer;
Returns current Acrux::Pointer object
HISTORY
See Changes
file
TO DO
See TODO
file
SEE ALSO
Config::General, Acrux::Pointer
AUTHOR
Serż Minus (Sergey Lepenkov) https://www.serzik.com <abalama@cpan.org>
COPYRIGHT
Copyright (C) 1998-2024 D&D Corporation. All Rights Reserved
LICENSE
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See LICENSE
file and https://dev.perl.org/licenses/