Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^3: Inherited Object Constructor Question

by chromatic (Archbishop)
on Sep 12, 2011 at 04:47 UTC ( #925402=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Inherited Object Constructor Question
in thread Inherited Object Constructor Question

I guess my biggest issue is I am not sure how to load my "plugins" with moose.

I use Module::Pluggable::Object:

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;

... and in a class which needs to use plugins:

package My::Project::SomeClass; use Moose; with 'My::Project::HasPlugins' { namespaces => [ 'Some::Plugin::Namespace' ] }; ... 1;

You can do this without the parametric role, but it worked really well for my project.


Improve your skills with Modern Perl: the free book.


Comment on Re^3: Inherited Object Constructor Question
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://925402]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2014-10-31 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (214 votes), past polls