View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Tomas Doran > Catalyst-Controller-ActionRole-0.12 > Catalyst::Controller::ActionRole



Annotate this POD


Open  0
View/Report Bugs
Module Version: 0.12   Source   Latest Release: Catalyst-Controller-ActionRole-0.17


Catalyst::Controller::ActionRole - Apply roles to action instances


version 0.12


    package MyApp::Controller::Foo;

    use parent qw/Catalyst::Controller::ActionRole/;

    sub bar : Local Does('Moo') { ... }


This module allows to apply roles to the Catalyst::Actions 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 ::ActionRole:: 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/;

        action_roles => ['Foo', '~Bar'],

    # has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied
    # if MyApp::ActionRole::Foo exists and is loadable, it will take
    # precedence over Catalyst::ActionRole::Foo
    sub moo : Local { ... }


Roles specified with no prefix are looked up under a set of role prefixes. The first prefix is always MyApp::ActionRole:: (with MyApp replaced as appropriate for your application); the following prefixes are taken from the _action_role_prefix attribute.



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::ActionRole::' ]. See "role prefix searching".


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 for Does will be performed.


  Florian Ragwitz <>
  Hans Dieter Pearcey <>


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.

syntax highlighting: