Ambrosia
view release on metacpan or search on metacpan
lib/Ambrosia/Config.pm view on Meta::CPAN
1;
__END__
=head1 NAME
Ambrosia::Config - a class for read a configuration data.
It implements the pattern B<Singleton>.
=head1 VERSION
version 0.010
=head1 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' };
=head1 DESCRIPTION
C<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.
=head2 instance
This method instantiates the named object of type C<Ambrosia::Config> in the pool.
This method not exported. Use as constructor: C<instance Ambrosia::Config(.....)>
C<instance(name => path)> - where the "name" is a keyname for config and the "path" is a path to config file.
C<instance(name => hash)> - where the "name" is a keyname for config and the "hash" is a config data.
=head2 config
Returns the global object of type C<Ambrosia::Config>.
C<config(name)> - the "name" is optional param. Call with "name" if you not assign current process to config.
=head2 assign ($name)
Assign current process to the global named object of type C<Ambrosia::Config>.
=head1 DEPENDENCIES
L<Ambrosia::core::Exceptions>
L<Ambrosia::Meta>
=head1 THREADS
Not tested.
=head1 BUGS
Please report bugs relevant to C<Ambrosia> to <knm[at]cpan.org>.
=head1 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.
=head1 AUTHOR
Nikolay Kuritsyn (knm[at]cpan.org)
=cut
( run in 1.389 second using v1.01-cache-2.11-cpan-df04353d9ac )