Skip Menu |

This queue is for tickets about the Module-Pluggable CPAN distribution.

Report information
The Basics
Id: 45275
Status: resolved
Priority: 0/
Queue: Module-Pluggable

People
Owner: Nobody in particular
Requestors: ddascalescu+perl [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Feature request: specify inside a plugin module that it shouldn't be loaded
This may seem perverse, but here's a use case for it: I'm working on MojoMojo, a wiki with a pluggable syntax. It has content formatters that parse the page content and output HTML from what they recognize as their own tags. E.g. the CPAN plugin moduel will parse {{cpan Some::Module}} into a <a href="http://search.cpan.org/perldoc?Some::Module">Some::Module</a>. We also have a Markdown plugin and a Textile plugin. The thing is that only one of the should parse the content at a time (based on user setting), but they should still have a the same ->parse method like all other plugins. A solution I thought of was to have a "Main" plugin which will dispatch to either the Textile or the Markdown plugin based on the user setting, and have the Markdown and Textile plugins not implement ->parse, but ->main_parse, and have Main call ->main_parse. However, it would be nice to keep the same method name, but have these two plugins somehow excluded from automatic loading. Does this make sense? For reference: http://github.com/marcusramberg/mojomojo/blob/23f062d76eaf0378a20e854bcfe12a730f176140/lib/MojoMojo/Schema/ResultSet/Content.pm#L21 -- calls all plugins (uses Module::Pluggable::Ordered) http://github.com/marcusramberg/mojomojo/blob/5b4d0d0411ef9099eac555f49c29170c13189c89/lib/MojoMojo/Formatter/Main.pm -- dispatches to Markdown or Textile (below) http://github.com/marcusramberg/mojomojo/blob/5b4d0d0411ef9099eac555f49c29170c13189c89/lib/MojoMojo/Formatter/Markdown.pm http://github.com/marcusramberg/mojomojo/blob/5b4d0d0411ef9099eac555f49c29170c13189c89/lib/MojoMojo/Formatter/Textile.pm
On Fri Apr 24 07:02:13 2009, dandv wrote: Show quoted text
> Does this make sense?
I've just created a new branch called triggers https://github.com/simonwistow/Module-Pluggable/tree/triggers that should help with this feature request. Have a look at https://github.com/simonwistow/Module-Pluggable/blob/triggers/t/22trigger.t in this case what you'd do is package MyModule; use Module::Pluggable require => 1, after_require => sub { my $p = shift; !($p->can('exclude_plugin') && $p->exclude_plugin) }; Can you take a look and see if that meets your needs?
Released as 4.1