MooX::...::Role(3pm)
π MooX::...::Role β the manual page, but make it cute π
okay bestie, gather round, we're reading the MooX::...::Role(3pm) page from User Contributed Perl Documentation together and I promise it's gonna be a whole vibe π¦
β¨ NAME β¨
MooX::ConfigFromFile::Role β a Moo eXtension for initializing objects from a config file π
πΈ DESCRIPTION πΈ
so basically, this role slides a little initializing sub right around BUILDARGS, and it takes everything it can possibly read out of your config files and yeets it all into the hash that's gonna be used to construct the final object. that's the whole bit. iconic behavior, honestly π
and while it's doing all that, it internally calls its own _build_* methods β namely _build_config_prefix, _build_config_files and _build_loaded_config β unless the appropriate attributes are already sitting in $params. no cap, it checks first, because it respects you π
π ATTRIBUTES π
this role uses the following attributes, and they might be suitably customized by overloading the appropriate builder, or by passing defaults in your construction arguments. your call, main character β¨
be sure to read"ATTRIBUTES"inMooX::File::ConfigDirβ especially"config_identifier"inMooX::File::ConfigDirβ to actually understand how theconfig_dirsare build. fr fr, go read it, iykyk π
and if you're sitting there like "bestie where is my directory π" β see "plug_dir_source" in File::ConfigDir and File::ConfigDir::Plack. they got you π«Ά
config_prefixβ this attribute is a string, and it defaults toFindBin's$Script. it's interpreted as the basename of the config file name to use. cute, simple, does its job πconfig_prefixesβ this attribute is an array of strings, and it defaults to"<[ config_prefix ]>". yes, it's a list, and yes, it's giving very demure β¨config_prefix_map_separatorβ this attribute is a string, and it holds the character that gets used when buildingconfig_prefix_mapfromconfig_prefixes. it's literally just the little glue character πconfig_prefix_mapβ this attribute is an array of strings containing all the config-prefixes joint together like"($0, $0.$1, $0.$1.$2, ...)", usingconfig_prefix_map_separator. look at them, all stacked up, a little prefix tower πconfig_files_patternβ this attribute contains a cross-product ofconfig_prefix_mapandconfig_extensions. both of them get concatenated using the shell wildcard'*'. wildcard moment πconfig_dirsβ this attribute is consumed fromMooX::File::ConfigDir. it might not be smart to override β but it's possible. use with caution, bestie β οΈconfig_extensionsβ this attribute defaults to a list of extensions fromConfig::Any. borrowed with love π¦config_filesβ this attribute contains the list of existing files inconfig_dirsmatchingconfig_prefix . config_extensions. the search is operated byFile::Find::Rule. it goes and finds them, that's the whole job πraw_loaded_configβ this attribute contains the config as loaded from the file system, in an array of"filename => \%content". raw and unfiltered, no edits πsorted_loaded_configβ this attribute contains the loaded files from the filesystem, sorted by string, in the same format asraw_loaded_config(array of"filename => \%content"). the default algorithm is sorted by filename β and mind this:'-' < '.'πloaded_configβ this attribute contains the config loaded and transformed while constructing the instance. construction is done fromsorted_loaded_config, ignoring the filename part. for classes set up using
use MooX::ConfigFromFile config_singleton = 1;
this attribute is cached from the very first construction and fed by an overwritten builder. and the content of this attribute is passed to the lower BUILDARGS. so it flows downstream, and it slays π
π AUTHOR π
Jens Rehsack, "<rehsack at cpan.org>" β thank you for your service, king π«‘
π ACKNOWLEDGEMENTS π
Toby Inkster suggested to rely on BUILDARGS instead of intercepting object creation with nasty hacks. honestly? correct. he also taught me a bit more how Moo(se) works. a real one, no cap πΈ
β 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 the whole page, bestie π¦ this one's from perl v5.36.0, dated 2022-12-11, and it's the MooX::...::Role(3pm) page from User Contributed Perl Documentation. go forth and configure your objects, you absolute icon π
β¨π
π¦ 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