note
chromatic
<blockquote><em>I guess my biggest issue is I am not sure how to load my "plugins" with moose.</em></blockquote>
<p>I use [CPAN://Module::Pluggable::Object]:</p>
<c>package My::Project::HasPlugins;
use MooseX::Role::Parameterized;
parameter 'namespaces', isa => 'ArrayRef', required => 1;
role
{
my $p = shift;
my $namespaces = $p->namespaces;
has 'plugins', is => 'ro', isa => 'ArrayRef', lazy_build => 1;
method _build_plugins => sub
{
return
[
Module::Pluggable::Object->new(
instantiate => 'new',
search_path => $namespaces,
)->plugins
];
};
}
1;</c>
<p>... and in a class which needs to use plugins:</p>
<c>package My::Project::SomeClass;
use Moose;
with 'My::Project::HasPlugins'
{ namespaces => [ 'Some::Plugin::Namespace' ] };
...
1;</c>
<p>You can do this without the parametric role, but it worked really well for
my project.</p>
<div class="pmsig"><div class="pmsig-1382">
<hr />
<p>Improve your skills with <a href="http://www.onyxneon.com/books/modern_perl/index.html">Modern Perl: the free book</a>.</p>
</div></div>
925374
925391