On Apr 8, 2010, at 05:46 , Dan Horne wrote:
> 
> I have a question regarding the best method for implementing application
> plugins - i.e. if there is an idiomatic way to do this in Moose. Here's a
> high level description of what I'm trying to achieve:

This thread, plus a project I'm working on, bounced around in my head with the 
code that Robin Smidsrød posted as well as what RJBS did for plugins in 
Dist::Zilla, and this morning out popped this:

<http://github.com/genehack/moosex-role-pluggable>

The basic idea is pretty simple, your Moose class just consumes the 
MooseX::Role::Pluggable role, and any plugins consume 
Moose::Role::Pluggable::Plugin, and then you call the 'new_with_plugins' 
constructor instead of 'new'. This looks for a 'plugins' attribute, which 
should be a list of class names to load; those are each instantiated and 
stuffed in a 'plugin_list' attribute. That can then be walked over or used in 
the type of operations that Shlomi is talking about in the 'walkmeth' thread 
(e.g., $class->do_all($plugin_method); $class->do_until_true( $plugin_method ); 
$class->do_until_false( $plugin_method ), etc.)

This is very raw at the moment but I thought I'd throw it out there and ask if 
this looks generally useful and generic enough to be worth fully fleshing out 
or if I'm totally barking up the wrong tree.

thanks,
john.


Reply via email to