[Catalyst] Plugin methods and context namespace
Sebastian Riedel
sri at oook.de
Fri Nov 25 01:37:19 CET 2005
Am 25.11.2005 um 01:22 schrieb Christopher H. Laco:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Sebastian Riedel wrote:
>>
>> Am 24.11.2005 um 23:36 schrieb John Wang:
>>
>>> To keep the $c context namespace cleaner, I'd like to add plugin
>>> methods like $c->myplugin->foo instead of $c->foo.
>>>
>>> I have this working by creating a package MyPlugin and a plugin
>>> wrapper Catalyst::Plugin::MyPlugin. The wrapper just does a few
>>> things:
>>>
>>> inherits from Class::Data::Inheritable
>>> uses MyPlugin
>>> adds 'myplugin' to classdata
>>> sets $c->myplugin( MyPlugin->new( $c ) ) in prepare
>>>
>>> This works, but having an external MyPlugin.pm doesn't seem very
>>> clean. Is there a better way to get plugin methods in the $c-
>>>> myplugin->foo format?
>>
>>
>> MyApp->plugin( 'prototype', 'HTML::Prototype' );
>>
>> $c->prototype->define_javascript_functions;
>>
>
> IS that only supported in MyApp.pm when the app loads, of can this be
> called at anytime/module when the app is running?
Anytime.
--
sebastian
More information about the Catalyst
mailing list