CatalystX::Controller::Sugar::Plugin - Prepare a plugin, not a real controller


CatalystX-Controller-Sugar documentation  | view source Contained in the CatalystX-Controller-Sugar distribution.

Index


NAME

Top

CatalystX::Controller::Sugar::Plugin - Prepare a plugin, not a real controller

DESCRIPTION

Top

This module prepare actions to be plugged in "somewhere" in another controller. This is done, by using the inject() method.

SYNOPSIS

Top

 #= 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.

EXPORTED FUNCTIONS

Top

chain

Same as CatalystX::Controller::Sugar::chain(), but will only prepare the action to be injected in some other controller.

private

Same as CatalystX::Controller::Sugar::private(), but will only prepare the action to be injected in some other controller.

has

Does the same as has in Moose, but sets lazy to true and is to "ro" by default.

METHODS

inject

 $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.

init_meta

See Moose::Exporter.

EXTENDED SYNOPSIS

Top

 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.

BUGS

Top

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 & LICENSE

Top

AUTHOR

Top

Jan Henning Thorsen, <jhthorsen at cpan.org>


CatalystX-Controller-Sugar documentation  | view source Contained in the CatalystX-Controller-Sugar distribution.