-
-
01 Apr 2009 19:22:17 UTC
- Distribution: Catalyst-Controller-ActionRole
- Module version: 0.07
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues (0)
- Testers (24 / 0 / 0)
- Kwalitee
Bus factor: 2- License: perl_5
- Activity
24 month- Tools
- Download (10.6KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Catalyst::Runtime
- Class::MOP
- Moose
- MooseX::Types::Moose
- String::RewritePrefix
- namespace::clean
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
NAME
Catalyst::Controller::ActionRole - Apply roles to action instances
VERSION
version 0.07
SYNOPSIS
package MyApp::Controller::Foo; use parent qw/Catalyst::Controller::ActionRole/; sub bar : Local Does('Moo') { ... }
DESCRIPTION
This module allows to apply roles to the
Catalyst::Action
s for different controller methods.For that a
Does
attribute is provided. That attribute takes an argument, that determines the role, which is going to be applied. If that argument is prefixed with+
, it is assumed to be the full name of the role. If it's prefixed with~
, the name of your application followed by::Action::Role::
is prepended. If it isn't prefixed with+
or~
, the role name will be searched for in@INC
according to the rules for "role prefix searching".Additionally it's possible to to apply roles to all actions of a controller without specifying the
Does
keyword in every action definition:package MyApp::Controller::Bar use parent qw/Catalyst::Controller::ActionRole/; __PACKAGE__->config( action_roles => ['Foo', '~Bar'], ); # has Catalyst::Action::Role::Foo and MyApp::Action::Role::Bar applied # if MyApp::Action::Role::Foo exists and is loadable, it will take # precedence over Catalyst::Action::Role::Foo sub moo : Local { ... }
ATTRIBUTES
_action_role_prefix
This class attribute stores an array reference of role prefixes to search for role names in if they aren't prefixed with
+
or~
. It defaults to[ 'Catalyst::Action::Role::' ]
. See "role prefix searching"._action_roles
This attribute stores an array reference of role names that will be applied to every action of this controller. It can be set by passing a
action_roles
argument to the constructor. The same expansions as forDoes
will be performed.AUTHORS
Florian Ragwitz <rafl@debian.org> Hans Dieter Pearcey <hdp@weftsoar.net>
COPYRIGHT AND LICENSE
This software is copyright (c) 2009 by Florian Ragwitz.
This is free software; you can redistribute it and/or modify it under the same terms as perl itself.
ROLE PREFIX SEARCHING
Roles specified with no prefix are looked up under a set of role prefixes. The first prefix is always
MyApp::Action::Role::
(withMyApp
replaced as appropriate for your application); the following prefixes are taken from the_action_role_prefix
attribute.Module Install Instructions
To install Catalyst::Controller::ActionRole, copy and paste the appropriate command in to your terminal.
cpanm Catalyst::Controller::ActionRole
perl -MCPAN -e shell install Catalyst::Controller::ActionRole
For more information on module installation, please visit the detailed CPAN module installation guide.