NAME
Config::Merge::Dynamic - load a configuration directory tree containing YAML, JSON, XML, Perl, INI or Config::General files AND alter it in runtime.
VERSION
Version 0.08
SYNOPSIS
Example how to add (or replace, if values exists) values in config object:
use Config::Merge::Dynamic;
my $config = Config::Merge->new('/path/to/config');
my $all_data = $config->inject( 'key_one.key_two.keyn', { foo =>'bar' } );
my $new_conf = $config->move( 'user_config', 'system_config' );
DESCRIPTION
This module expand Config::Merge to make available to add/replace config data in config object in runtime.
SUBROUTINES/METHODS
Config::Merge::Dynamic inherits all methods from Config::Merge and implements the following new ones.
inject($path?, $what)
inject() are insert to object config new data, and context-sensetive returns of all new config data, or nothing if called in void context.
First argument - path is optional, second may be scalar or arrayref or hashref.
my $all_data = $config->inject( 'key_one.key_two.keyn', { foo =>'bar' } );
Or available one-argument calling, without 'path', all data will injected to root:
my $all_data2 = $config->inject(
{
key_one => {
key_two => {
keyn => {
foo => 'bar'
}
}
}
}
);
Also available to change single scalar value
my $all_data3 = $config->inject( 'key_one.key_two.keyn.foo', 'bar' );
And deal with array like this
my $all_data3 = $config->inject( 'key_three.1', 'bar' );
# now $all_data3 = { key_three => [ undef, 'bar' ], ... };
move($source, $destination?)
move() are move one part of config data to another place (in dot-notation), and context-sensetive returns of all new config data, or nothing if called in void context.
First argument - source requared, second - destination is optional. If destination is omitted source was move to the `root` of config.
my $new_conf = $config->move( 'user_config', 'system_config' );
# or move 'user_config' content to `root`
$config->move( 'user_config' );
CAVEAT
All may go strange if you inject mismatch type of values in wrong place - handle your data with care.
EXPORT
Nothing by default.
AUTHOR
Meettya, <meettya at cpan.org>
BUGS
Please report any bugs or feature requests to bug-config-merge-dynamic at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Config-Merge-Dynamic. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
DEVELOPMENT
Repository
https://github.com/Meettya/Config-Merge-Dynamic
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Config::Merge::Dynamic
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=Config-Merge-Dynamic
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Thanks to Clinton Gormley, <clinton@traveljury.com> for original Config::Merge.
LICENSE AND COPYRIGHT
Copyright 2011 Meettya.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.