[Catalyst] Plugin methods and context namespace
Christopher H. Laco
claco at chrislaco.com
Fri Nov 25 01:22:15 CET 2005
-----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?
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
iD8DBQFDhlk3+66dLHM50ssRAgxeAKCAN9ti3HeLEAnaQzOb02ji7ATqCgCgpvlw
Vb7k/ZLkOZlYfpSNk04U9ug=
=ZKSp
-----END PGP SIGNATURE-----
More information about the Catalyst
mailing list