NAME

Config::MVP::Section - one section of an MVP configuration sequence

VERSION

version 2.200013

DESCRIPTION

For the most part, you can just consult Config::MVP to understand what this class is and how it's used.

PERL VERSION

This module should work on any version of perl still receiving updates from the Perl 5 Porters. This means it should work on any version of perl released in the last two to three years. (That is, if the most recently released version is v5.40, then this module should work on both v5.40 and v5.38.)

Although it may work on older versions of perl, no guarantee is made that the minimum required version will not be increased. The version may be increased for any reason, and there is no promise that patches will be accepted to lower the minimum required perl.

ATTRIBUTES

name

This is the section's name. It's a string, and it must be provided.

package

This is the (Perl) package with which the section is associated. It is optional. When the section is instantiated, it will ensure that this package is loaded.

multivalue_args

This attribute is an arrayref of value names that should be considered multivalue properties in the section. When added to the section, they will always be wrapped in an arrayref, and they may be added to the section more than once.

If this attribute is not given during construction, it will default to the result of calling section's package's mvp_multivalue_args method. If the section has no associated package or if the package doesn't provide that method, it default to an empty arrayref.

aliases

This attribute is a hashref of name remappings. For example, if it contains this hashref:

{
  file => 'files',
  path => 'files',
}

Then attempting to set either the "file" or "path" setting for the section would actually set the "files" setting.

If this attribute is not given during construction, it will default to the result of calling section's package's mvp_aliases method. If the section has no associated package or if the package doesn't provide that method, it default to an empty hashref.

payload

This is the storage into which properties are set. It is a hashref of names and values. You should probably not alter the contents of the payload, and should read its contents only.

is_finalized

This attribute is true if the section has been marked finalized, which will prevent any new values from being added to it. It can be set with the finalize method.

sequence

This attributes points to the sequence into which the section has been assembled. It may be unset if the section has been created but not yet placed in a sequence.

METHODS

add_value

$section->add_value( $name => $value );

This method sets the value for the named property to the given value. If the property is a multivalue property, the new value will be pushed onto the end of an arrayref that will store all values for that property.

Attempting to add a value for a non-multivalue property whose value was already added will result in an exception.

load_package

$section->load_package($package, $section_name);

This method is used to ensure that the given $package is loaded, and is called whenever a section with a package is created. By default, it delegates to Class::Load. If the package can't be found, it calls the missing_package method. Errors in compilation are not suppressed.

missing_package

$section->missing_package($package, $section_name);

This method is called when load_package encounters a package that is not installed. By default, it throws an exception.

AUTHOR

Ricardo Signes <cpan@semiotic.systems>

COPYRIGHT AND LICENSE

This software is copyright (c) 2022 by Ricardo Signes.

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