| CatalystX-Controller-Sugar documentation | view source | Contained in the CatalystX-Controller-Sugar distribution. |
CatalystX::Controller::Sugar::Plugin - Prepare a plugin, not a real controller
This module prepare actions to be plugged in "somewhere" in another controller. This is done, by using the inject() method.
#= first... ==============================
package My::Plugin;
use CatalystX::Controller::Sugar::Plugin;
# Same as L<CatalystX::Controller::Sugar>.
1;
#= then... ===============================
package MyApp::Controller::Foo;
My::Plugin->inject;
1;
#= or... =================================
package MyApp;
My::Plugin->inject("MyApp::Controller::Foo");
1;
See EXTENDED SYNOPSIS for how to include attributes.
Same as CatalystX::Controller::Sugar::chain(), but will only prepare the action to be injected in some other controller.
Same as CatalystX::Controller::Sugar::private(), but will only prepare the action to be injected in some other controller.
Does the same as has in Moose, but sets lazy to true and is to "ro"
by default.
$controller_obj = $class->inject; $controller_obj = $class->inject($target);
Will inject the prepared actions into $target namespace or caller's
namespace by default. This will also inject attributes from the plugin
package, but will not override any existing attributes with the same name.
Also the $target controller will be spawned, unless it already exists
in the component list.
See Moose::Exporter.
package My::Plugin;
use CatalystX::Controller::Sugar::Plugin;
has foo => (
is => 'ro', <-- Default by CatalystX::Controller::Sugar::Plugin
isa => 'Str',
lazy => 1, # <-- Default by CatalystX::Controller::Sugar::Plugin
default => 'foo value'
);
chain '' => sub {
};
#...
1;
Attributes with default values has to be lazy. (Not quite sure why though...) All attributes defined in a plugin package, will also be injected into the caller controller. They are cloned and not shared among the controller, if it is injected into multiple controllers.
Please report any bugs or feature requests to
bug-catalystx-controller-sugar at rt.cpan.org.
I will be notified, and then you'll automatically be notified of progress on
your bug as I make changes.
Copyright 2007 Jan Henning Thorsen, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Jan Henning Thorsen, <jhthorsen at cpan.org>
| CatalystX-Controller-Sugar documentation | view source | Contained in the CatalystX-Controller-Sugar distribution. |