NAME
MooX::PluginKit::Consumer - Declare a class as a consumer of PluginKit plugins.
SYNOPSIS
package My::Class;
use Moo;
use MooX::PluginKit::Consumer;
# Optional, defaults to just 'My::Class'.
plugin_namespace 'My::Class::Plugin';
has_pluggable_object some_object => (
class => 'Some::Object',
);
my $object = My::Class->new(
plugins => [...],
some_object=>{...},
);
DESCRIPTION
This module, when use
d, sets the callers base class to the MooX::PluginKit::ConsumerBase class, applies the MooX::PluginKit::ConsumerRole role to the caller, and exports several candy functions (see "CANDY") into the caller.
Some higher-level documentation about how to consume plugins can be found at "CONSUMING PLUGINS" in MooX::PluginKit.
CANDY
plugin_namespace
plugin_namespace 'Location::Of::My::Plugins';
When the "plugins" in MooX::PluginKit::ConsumerRole argument is set the user may choose to pass relative plugins. Setting this namespace changes the default root namespace used to resolve these relative plugin names to absolute ones.
This defaults to the package name of the class which uses this module.
Read more about this at "Relative Plugin Namespace" in MooX::PluginKit.
has_pluggable_object
has_pluggable_object foo_bar => (
class => 'Foo::Bar',
);
This function acts like "has" in Moo but adds a bunch of functionality, making it easy to cascade the creation of objects which automatically have applicable plugins applied to them, at run-time.
In the above foo_bar
example, the user of your class can then specify the foo_bar
argument as a hashref. This hashref will be used to create an object of the Foo::Bar
class, but not until after any applicable plugins set on the consumer class have been applied to it.
This function only support a subset of the arguments that "has" in Moo supports. They are:
handles
default
builder
required
weak_ref
init_arg
Any other arguments will be ignored.
Read more about this at "Object Attributes" in MooX::PluginKit.
AUTHORS AND LICENSE
See "AUTHOR" in MooX::PluginKit and "LICENSE" in MooX::PluginKit.