Config::Merge::Dynamic - load a configuration directory tree containing YAML, JSON, XML, Perl, INI or Config::General files AND alter it in runtime.
Version 0.14.1
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' );
This module expand Config::Merge to make available to add/replace config data in config object in runtime.
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' );
All may go strange if you inject mismatch type of values in wrong place - handle your data with care.
Nothing by default.
Meettya, <meettya at cpan.org>
<meettya at cpan.org>
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.
bug-config-merge-dynamic at rt.cpan.org
https://github.com/Meettya/Config-Merge-Dynamic
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
http://annocpan.org/dist/Config-Merge-Dynamic
CPAN Ratings
http://cpanratings.perl.org/d/Config-Merge-Dynamic
Search CPAN
http://search.cpan.org/dist/Config-Merge-Dynamic/
Thanks to Clinton Gormley, <clinton@traveljury.com> for original Config::Merge.
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.
To install Config::Merge::Dynamic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Config::Merge::Dynamic
CPAN shell
perl -MCPAN -e shell install Config::Merge::Dynamic
For more information on module installation, please visit the detailed CPAN module installation guide.