The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

MooX::PluginKit::Factory - Dynamically apply plugins to classes at runtime.

SYNOPSIS

    use MooX::PluginKit::Factory;
    
    my $kit = MooX::PluginKit::Factory->new(
        plugins => [...],
        namespace => ...,
    );
    
    my $object = $kit->class_new('Some::Class', %args);

DESCRIPTION

A PluginKit factory takes a list of plugins and then provides methods for applying those plugins to classes and building objects from those classes.

Unless you are a power user you are better off using MooX::PluginKit::Consumer.

ARGUMENTS

plugins

An array ref of plugin names (relative or absolute).

namespace

The namespace to resolve relative plugin names to.

ATTRIBUTES

resolved_plugins

"plugins" with all relative plugin names resolved.

METHODS

build_class

    my $new_class = $kit->build_class( $class );

Creates a new class with all applicable "plugins" applied to it and returns the new class name.

class_new

    my $object = $kit->class_new( $class, %args );

Calls "build_class" and then creates an object of that class. If the class to be built is a plugin consumer then "plugin_factory" in MooX::PluginKit::ConsumerRole will be defaulted to this factory.

AUTHORS AND LICENSE

See "AUTHORS" in MooX::PluginKit and "LICENSE" in MooX::PluginKit.