NAME

Ambrosia::Config - a class for read a configuration data. It implements the pattern Singleton.

VERSION

version 0.010

SYNOPSIS

#In the file "test.pl"
use Ambrosia::Config;
use Foo;
BEGIN
{
    instance Ambrosia::Config( myApplication => './foo.conf' );
};
Ambrosia::Config::assign 'myApplication';
#..............
say Foo::proc1();
#..............

#In the file "Foo.pm"
package Foo;
use Ambrosia::Config;

sub proc1
{
    return config->ParamA;
}

1;

#In the config file "foo.conf"
return { ParamA => 'ABC' };

DESCRIPTION

Ambrosia::Config is a class of object Ambrosia::Config. The file of config is the perl script that MUST return reference to hash. Each key of the hash becomes a method of object of type Ambrosia::Config that return an appropriate value.

WARNING! This method is "lvalue" and you can modify a config value on the fly.

instance

This method instantiates the named object of type Ambrosia::Config in the pool. This method not exported. Use as constructor: instance Ambrosia::Config(.....) instance(name => path) - where the "name" is a keyname for config and the "path" is a path to config file. instance(name => hash) - where the "name" is a keyname for config and the "hash" is a config data.

config

Returns the global object of type Ambrosia::Config. config(name) - the "name" is optional param. Call with "name" if you not assign current process to config.

assign ($name)

Assign current process to the global named object of type Ambrosia::Config.

DEPENDENCIES

Ambrosia::core::Exceptions Ambrosia::Meta

THREADS

Not tested.

BUGS

Please report bugs relevant to Ambrosia to <knm[at]cpan.org>.

COPYRIGHT AND LICENSE

Copyright (C) 2010-2012 Nickolay Kuritsyn. All rights reserved.

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

AUTHOR

Nikolay Kuritsyn (knm[at]cpan.org)