NAME
Catalyst::Plugin::C3 - Catalyst Plugin to subvert NEXT to use Class::C3
SYNOPSIS
Use it in an application:
package MyCatApp;
use Catalyst qw/ -Debug C3 Static::Simple /;
Use it in another plugin:
package Catalyst::Plugin::FooBar;
use base qw/ Catalyst::Plugin::C3 /;
DESCRIPTION
*** WARNING *** THIS MODULE IS NOT FOR GENERAL PUBLIC CONSUMPTION JUST YET.
This module is related to the possible transition of Catalyst from NEXT to Class::C3. This module is a developer release only, and is not intended for any sort of production use by anyone at this time. This module will be upgraded to 0.02 and released if/when it seems like a good idea for people other than Catalyst module developers to look at it and/or use it.
This module makes the use of the following idiom:
use NEXT;
sub foo {
my $self = shift->NEXT::foo(@_);
}
actually accomplish something more like:
use Class::C3;
sub foo {
my $self = shift->next::method(@_);
}
It does this by essentially pre-pending some functionality to "AUTOLOAD" in NEXT which transforms the call into Class::C3's next::method
call, but only when certain specific conditions are met.
Those conditions are that the object ->NEXT
is being used on is a Catalyst-related object of some sort, and that the inheritance heirarchy of the object's class is C3-compatible.
If either of those conditions do not hold true, the ->NEXT
call should do things the normal NEXT way.
If you are going to place this module in your plugins list for a Catalyst app, it is best placed at the top of the list, above all other plugins. A good reason to stick this in your plugins list is that it can give a noticeable performance boost in the case that you're using lots of Plugins and other Catalyst components which still use NEXT rather than Class::C3.
Some other plugins that have real end-user functionality may require this plugin as a base-class in order to transition themselves to Class::C3 without worrying about being broken by other plugins which haven't made the transition. Most plugins will *not* need to do so. Any that do would have wierd hacks involving *{NEXT::NEXT}
in them prior to their C3 conversion, so you'd know it.
Or in other words, a plugin should only base on this plugin if it needed NEXT hacks to work right under NEXT, and you're transitioning it to use Class::C3.
METHODS
handle_request
This plugin hooks into the handle_request
method, sets up a local
override of the standard version of "AUTOLOAD" in NEXT for the entire request, and then calls up the chain to the next class on the list.
AUTHOR
Brandon Black blblack@gmail.com
COPYRIGHT
This program is free software, you can redistribute it and/or modify it under the same terms as Perl itself.