package Template::TT2::Plugins;

use Badger::Factory::Class
    version   => 3.14,
    debug     => 0,
    item      => 'plugin',
    path      => 'Template::TT2::Plugin Template::Plugin',
    plugins   => {
        extra => 'Special::Case::Plugin',
Thus Spake Andy:

Here's an example of specialised class metaprogramming module (i.e. a subclass of Badger::Class) which is used to construct factory modules. In this case, it's Template::TT2:Plugins which is responsible for finding, loading and instantiating TT plugin objects (Template::TT2 is a new implementation of TT written on top of Badger - due out this week). This is a slightly simplified version of the real code, but it demonstrates how we've got some custom hooks (item and path) which are specialised to factory modules. There's also a bit of trickery going on when we declare the fact that the factory creates plugin items. This adds the plugins hook on-the-fly that we then use two lines below to define any special cases. In this case we know that 'plugin' pluralises regularly to 'plugins', otherwise we can use an additional items hook to specify what the plural form should be.