.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MooX::ConfigFromFile 3pm" .TH MooX::ConfigFromFile 3pm "2022-12-11" "perl v5.36.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MooX::ConfigFromFile \- Moo eXtension for initializing objects from config file .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package Role::Action; \& \& use Moo::Role; \& \& has operator => ( is => "ro" ); \& \& package Action; \& \& use Moo; \& use MooX::ConfigFromFile; # imports the MooX::ConfigFromFile::Role \& \& with "Role::Action"; \& \& sub operate { return say shift\->operator; } \& \& package OtherAction; \& \& use Moo; \& \& with "Role::Action", "MooX::ConfigFromFile::Role"; \& \& sub operate { return warn shift\->operator; } \& \& package QuiteOtherOne; \& \& use Moo; \& \& # consumes the MooX::ConfigFromFile::Role but load config only once \& use MooX::ConfigFromFile config_singleton => 1; \& \& with "Role::Action"; \& \& sub _build_config_prefix { "die" } \& \& sub operate { return die shift\->operator; } \& \& package main; \& \& my $action = Action\->new(); # tries to find a config file in config_dirs and loads it \& my $other = OtherAction\->new( config_prefix => "warn" ); # use another config file \& my $quite_o = QuiteOtherOne\->new(); # quite another way to have an individual config file .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module is intended to easy load initialization values for attributes on object construction from an appropriate config file. The building is done in MooX::ConfigFromFile::Role \- using MooX::ConfigFromFile ensures the role is applied. .PP For easier usage, with 0.004, several options can be passed via \fIuse\fR resulting in default initializers for appropriate role attributes: .ie n .IP """config_prefix""" 4 .el .IP "\f(CWconfig_prefix\fR" 4 .IX Item "config_prefix" Default for \*(L"config_prefix\*(R" in MooX::ConfigFromFile::Role. .ie n .IP """config_prefixes""" 4 .el .IP "\f(CWconfig_prefixes\fR" 4 .IX Item "config_prefixes" Default for \*(L"config_prefixes\*(R" in MooX::ConfigFromFile::Role. Ensure when use this flag together with MooX::Cmd to load \f(CW\*(C`MooX::ConfigFromFile\*(C'\fR before \&\f(CW\*(C`MooX::Cmd\*(C'\fR. .ie n .IP """config_prefix_map_separator""" 4 .el .IP "\f(CWconfig_prefix_map_separator\fR" 4 .IX Item "config_prefix_map_separator" Default for \*(L"config_prefix_map_separator\*(R" in MooX::ConfigFromFile::Role. .Sp .Vb 1 \& package Foo; \& \& # apply role MooX::ConfigFromFile::Role and override default for \& # attribute config_prefix_map_separator \& use MooX::ConfigFromFile config_prefix_map_separator => "~"; \& \& ... .Ve .ie n .IP """config_extensions""" 4 .el .IP "\f(CWconfig_extensions\fR" 4 .IX Item "config_extensions" Default for \*(L"config_extensions\*(R" in MooX::ConfigFromFile::Role. .ie n .IP """config_dirs""" 4 .el .IP "\f(CWconfig_dirs\fR" 4 .IX Item "config_dirs" Default for \*(L"config_dirs\*(R" in MooX::ConfigFromFile::Role. Same warning regarding modifying this attribute applies here: Possible, but use with caution! .Sp .Vb 1 \& package Foo; \& \& use MooX::ConfigFromFile config_dirs => [qw(/opt/foo/etc /home/alfred/area/foo/etc)]; \& \& ... .Ve .ie n .IP """config_files""" 4 .el .IP "\f(CWconfig_files\fR" 4 .IX Item "config_files" Default for \*(L"config_files\*(R" in MooX::ConfigFromFile::Role. .Sp Reasonable when you want exactly one config file in development mode. For production code it is highly recommended to override the builder. .ie n .IP """config_singleton""" 4 .el .IP "\f(CWconfig_singleton\fR" 4 .IX Item "config_singleton" Flag adding a wrapper around the \fIbuilder\fR of \*(L"loaded_config\*(R" in MooX::ConfigFromFile::Role to ensure a config is loaded only once per class. The \fIper class\fR restriction results from applicable modifiers per class (and singletons are per class). .ie n .IP """config_identifier""" 4 .el .IP "\f(CWconfig_identifier\fR" 4 .IX Item "config_identifier" Default for \*(L"config_identifier\*(R" in MooX::File::ConfigDir. .Sp .Vb 1 \& package Foo; \& \& # apply role MooX::ConfigFromFile::Role and override default for \& # attribute config_identifier \- means to look e.g. in /etc/foo/ \& use MooX::ConfigFromFile config_identifier => "foo"; \& \& ... .Ve .ie n .IP """config_hashmergeloaded""" 4 .el .IP "\f(CWconfig_hashmergeloaded\fR" 4 .IX Item "config_hashmergeloaded" Consumes role MooX::ConfigFromFile::Role::HashMergeLoaded directly after MooX::ConfigFromFile::Role has been consumed. .SH "AUTHOR" .IX Header "AUTHOR" Jens Rehsack, \f(CW\*(C`\*(C'\fR .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests to \&\f(CW\*(C`bug\-moox\-configfromfile at rt.cpan.org\*(C'\fR, or through the web interface at . I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. .SH "SUPPORT" .IX Header "SUPPORT" You can find documentation for this module with the perldoc command. .PP .Vb 1 \& perldoc MooX::ConfigFromFile .Ve .PP You can also look for information at: .IP "\(bu" 4 \&\s-1RT: CPAN\s0's request tracker (report bugs here) .Sp .IP "\(bu" 4 AnnoCPAN: Annotated \s-1CPAN\s0 documentation .Sp .IP "\(bu" 4 \&\s-1CPAN\s0 Ratings .Sp .IP "\(bu" 4 Search \s-1CPAN\s0 .Sp .SH "ACKNOWLEDGEMENTS" .IX Header "ACKNOWLEDGEMENTS" .SH "LICENSE AND COPYRIGHT" .IX Header "LICENSE AND COPYRIGHT" Copyright 2013\-2018 Jens Rehsack. .PP This program is free software; you can redistribute it and/or modify it under the terms of either: the \s-1GNU\s0 General Public License as published by the Free Software Foundation; or the Artistic License. .PP See for more information.