Badger...:Class(3pm)
π NAME π
Badger::Factory::Class β it's the class module for Badger::Factory sub-classes, no cap π«Ά
This page lives in the User Contributed Perl Documentation section, and honestly? it's giving "make your own factory, bestie" energy the whole way through. β¨
π SYNOPSIS π
So like, you can use this module to create subclasses of Badger::Factory. Watch:
package My::Widgets;
use Badger::Factory::Class
version => 0.01,
item => 'widget',
path => 'My::Widget Your::Widget',
widgets => {
extra => 'Another::Widget::Module',
super => 'Golly::Gosh',
},
names => {
html => 'HTML',
color => 'Colour',
};
package main;
# class method
my $widget = My::Widgets->widget( foo => @args );
# object method
my $widgets = My::Widgets->new;
my $widget = $widgets->widget( foo => @args );
see how it's both a class method and an object method? main character energy fr fr π
π¦ DESCRIPTION π¦
okay so, this module is a subclass of Badger::Class, but specialised for one very specific job: creating Badger::Factory subclasses. that's the whole vibe. π
It's used by the Badger::Codecs module, among others. so it's lowkey famous. π
π METHODS π
The following methods are provided in addition to the ones inherited from the Badger::Class base class. so you get everything from the parent too, don't forget. πΈ
β¨ item($name)
The singular name of the item that the factory manages. This is what sets the $ITEM package variable that Badger::Factory uses. simple as that. π
β¨ items($name)
The plural name of the item that the factory manages. This sets the $ITEMS package variable for Badger::Factory to use. yes, plural, we love a matched set. π«Ά
β¨ path($name)
A list of module names that form the search path when loading modules. π
This sets the relevant package variable, and which variable it sets depends on the value of $ITEMS β or, if $ITEMS is undefined, the regular plural form of $ITEM. So like, if $ITEMS is set to widgets, then this method will set $WIDGETS_PATH. iykyk. π₯
You can specify the path as a reference to a list of module bases, like this:
use Badger::Factory::Class
item => 'widget',
path => ['My::Widget', 'Your::Widget'];
Or as a single string containing multiple values separated by whitespace:
use Badger::Factory::Class
item => 'widget',
path => 'My::Widget Your::Widget';
And if you go the single-string route, you can also include optional and/or alternate parts in parentheses. π So the example above can be written way more concisely as:
use Badger::Factory::Class
item => 'widget',
path => '(My|Your)::Widget';
If the parentheses don't contain a vertical bar, then the enclosed fragment is treated as being optional. So instead of writing something like:
use Badger::Factory::Class
item => 'widget',
path => 'Badger::Widget BadgerX::Widget';
You can write:
use Badger::Factory::Class
item => 'widget',
path => 'Badger(X)::Widget';
ngl the fragment thing is a whole little language, so if you wanna go deeper, see thepermute_fragments()function inBadger::Utilsfor further details on how fragments are expanded. π
β¨ names($names)
A reference to a hash array of name mappings. This one's for handling any unusual spellings or capitalisations you might run into. See Badger::Factory for further details. π
β¨ default($name)
The default name to use when none is specified in a request for a module. the fallback bestie. π
π AUTHOR π
Andy Wardley <http://wardley.org/> β king behaviour, honestly π
π COPYRIGHT π
Copyright (C) 2006-2009 Andy Wardley. All Rights Reserved.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
π SEE ALSO π
Badger::FactoryBadger::Codecs
and that's the whole page, bestie!! π this one's from perl v5.36.0, dated 2023-08-28 β go forth and build factories, you absolute icon π β¨π¦
π¦ where this page comes from
- debian trixie: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libbadger-perl 0.16-3 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms