Adam Flott > Thorium > Thorium::Conf

Download:
Thorium-0.510.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.510   Source  

NAME ^

Thorium::Conf - Configuration class

VERSION ^

version 0.510

SYNOPSIS ^

Extending:

    package Some::App::Conf;

    use Moose;

    extends 'Thorium::Conf';

    has '+component_name' => ('default' => 'someapp');
    has '+component' => ('default' => [ '/file1.yaml', '/file2.yaml' ]);

    1;

But you may also use it directly:

    use Thorium::Conf;

    my $conf = Thorium::Conf->new('from' => '/that/app.yaml');

    print $conf->data('some.key');

    ...

DESCRIPTION ^

Thorium::Conf is an extendable class for handling configuration data in YAML http://yaml.org format through YAML::XS.

Data is accessed through a string interface that maps directly to the key names of a hash. Data is loaded in the order of (first to last): global, system, component, env_var, from. With each overriding data from the previous, e.g. component's a key would override systems's a key. All data is marked read-only to prevent accidental modification, but there is an interface to control this.

In nearly all cases you should sub-class and override the component_name and component attributes. See the "SYNOPSIS" for an example. component maps to the base file name that will be found in the system location (as set by _system_directory_root). Therefore, if your component name is someapp, then you'd expect the system wide file to reside in /etc/thorium/conf/someapp.yaml.

/etc/thorium/conf/thorium.yaml is the universally global file all Thorium::Conf and sub-classed objects read (when it exists).

ROLES ^

Thorium::Roles::Logging

ATTRIBUTES ^

Optional Attributes

PUBLIC API METHODS ^

AUTHOR ^

Adam Flott <adam@npjh.com>

COPYRIGHT AND LICENSE ^

This software is copyright (c) 2011 by Adam Flott <adam@npjh.com>, CIDC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

syntax highlighting: