NAME
Config::MVP::Assembler - multivalue-property config-loading state machine
VERSION
version 0.092080
DESCRIPTION
Config::MVP::Assembler is a helper for constructing a Config::MVP::Sequence object.
TYPICAL USE
my $assembler = Config::MVP::Assembler->new;
# Maybe you want a starting section:
my $section = $assembler->section_class->new({ name => '_' });
$assembler->sequence->add_section($section);
# We'll add some values, which will go to the starting section:
$assembler->add_value(x => 10);
$assembler->add_value(y => 20);
# Change to a new section...
$assembler->change_section($moniker);
# ...and add values to that section.
$assembler->add_value(x => 100);
$assembler->add_value(y => 200);
The code above creates an assembler and populates it step by step. In the end, to get values, you could do something like this:
my @output;
for my $section ($assembler->sequence->sections) {
push @output, [ $section->name, $section->package, $section->payload ];
}
When changing sections, the given section "moniker" is used for the new section name. The result of passing that moniker to the assembler's "expand_package"
method is used as the section's package name. (By default, this method does nothing.) The new section's multivalue_args
and aliases
are determined by calling the mvp_multivalue_args
and mvp_aliases
methods on the package.
AUTHOR
Ricardo Signes <rjbs@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Ricardo Signes.
This is free software; you can redistribute it and/or modify it under the same terms as perl itself.