MooX::...omFile(3pm)
MooX::ConfigFromFile π
okay bestie so this is a User Contributed Perl Documentation page, manual section 3pm, for a lil module called MooX::ConfigFromFile. it's giving "Moo eXtension for initializing objects from config file" and honestly? iconic. π
β¨ NAME β¨
MooX::ConfigFromFile β the Moo eXtension that initializes your objects straight from a config file. no cap. π¦
π SYNOPSIS π
here's the whole vibe, literally copy-paste this:
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
likeβ¦ the range?? the versatility?? we love to see it. πΈ
π DESCRIPTION π
so here's the tea: this module is intended to easy load initialization values for attributes on object construction from an appropriate config file. the actual building work happens over in MooX::ConfigFromFile::Role β and using MooX::ConfigFromFile is how you make sure that role gets applied. periodt. π
and for easier usage (as of 0.004, bestie, we've been upgraded β¨), several options can be passed via use, which gives you default initializers for the appropriate role attributes:
config_prefixβ sets the default forconfig_prefixinMooX::ConfigFromFile::Role. π«Άconfig_prefixesβ sets the default forconfig_prefixesinMooX::ConfigFromFile::Role. and bestie, listen: ensure that when you use this flag together withMooX::Cmd, you loadMooX::ConfigFromFilebeforeMooX::Cmd. order matters, it's giving choreography. πconfig_prefix_map_separatorβ sets the default forconfig_prefix_map_separatorinMooX::ConfigFromFile::Role.
package Foo;
# apply role MooX::ConfigFromFile::Role and override default for
# attribute config_prefix_map_separator
use MooX::ConfigFromFile config_prefix_map_separator => "~";
...
config_extensionsβ sets the default forconfig_extensionsinMooX::ConfigFromFile::Role. πconfig_dirsβ sets the default forconfig_dirsinMooX::ConfigFromFile::Role. and the same warning about modifying this attribute applies here too: possible, but use with caution! π
package Foo;
use MooX::ConfigFromFile config_dirs => [qw(/opt/foo/etc /home/alfred/area/foo/etc)];
...
config_filesβ sets the default forconfig_filesinMooX::ConfigFromFile::Role.
this one's reasonable when you want exactly one config file in development mode. but for production code? it is highly recommended to override the builder instead. fr fr. π₯
config_singletonβ a flag that adds a wrapper around the builder ofloaded_configinMooX::ConfigFromFile::Role, ensuring a config gets loaded only once per class. the per-class restriction comes from the applicable modifiers per class (and singletons are per class, iykyk). πconfig_identifierβ sets the default forconfig_identifierinMooX::File::ConfigDir.
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";
...
config_hashmergeloadedβ consumes the roleMooX::ConfigFromFile::Role::HashMergeLoadeddirectly afterMooX::ConfigFromFile::Rolehas been consumed. main character energy. β¨
π AUTHOR π
Jens Rehsack, "<rehsack at cpan.org>" π (yes, legend behaviour)
π¦ BUGS π¦
please report any bugs or feature requests to "bug-moox-configfromfile at rt.cpan.org", or slide through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=MooX-ConfigFromFile>. π
Jens will be notified, and then you'll automatically be notified of progress on your bug as changes get made. that's the communication, bestie. π«Ά
π SUPPORT π
you can find documentation for this module with the perldoc command:
perldoc MooX::ConfigFromFile
and you can also look for information at:
- RT: CPAN's request tracker (report bugs here) β <http://rt.cpan.org/NoAuth/Bugs.html?Dist=MooX-ConfigFromFile>
- AnnoCPAN: Annotated CPAN documentation β <http://annocpan.org/dist/MooX-ConfigFromFile>
- CPAN Ratings β <http://cpanratings.perl.org/d/MooX-ConfigFromFile>
- Search CPAN β <http://search.cpan.org/dist/MooX-ConfigFromFile/>
π ACKNOWLEDGEMENTS π
(nothing here bestie β literally empty, it's giving mysterious. π)
β LICENSE AND COPYRIGHT β
Copyright 2013-2018 Jens Rehsack.
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.
and that's a wrap, bestie π«Ά this was MooX::...omFile(3pm), served up by perl v5.36.0, dated 2022-12-11. stay configured, stay iconic, mwah ππΈβ¨
π¦ where this page comes from
- debian bookworm: libmoox-configfromfile-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libmoox-configfromfile-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libmoox-configfromfile-perl 0.009-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu questing: libmoox-configfromfile-perl 0.009-3
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms