The following methods are provided in addition to those inherited from the Badger::Class base class.
item($name)
The singular name of the item that the factory manages. This is used to set the $ITEM package variable
for Badger::Factory to use.
items($name)
The plural name of the item that the factory manages. This is used to set the $ITEMS package variable
for Badger::Factory to use.
path($name)
A list of module names that form the search path when loading modules. This will set the relevant package
variable depending on the value of $ITEMS (or the regular plural form of $ITEM if $ITEMS is undefined).
For example, is $ITEMS is set to "widgets" then this method will set $WIDGETS_PATH.
You can specify the path as a reference to a list of module bases, e.g.
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';
If you specify it as a single string then you can also include optional and/or alternate parts in
parentheses. For example the above can be written more concisely as:
use Badger::Factory::Class
item => 'widget',
path => '(My|Your)::Widget';
If the parentheses don't contain a vertical bar then then 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';
See the permute_fragments() function in Badger::Utils for further details on how fragments are expanded.
names($names)
A reference to a hash array of name mappings. This can be used to handle any unusual spellings or
capitalisations. See Badger::Factory for further details.
default($name)
The default name to use when none is specified in a request for a module.