GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages


Manual Reference Pages  -  CATALYST::CONTROLLER::ACTIONROLE (3)

.ds Aq ’

NAME

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

CONTENTS

SYNOPSIS



    package MyApp::Controller::Foo;

    use Moose;
    use namespace::autoclean;

    BEGIN { extends Catalyst::Controller::ActionRole }

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



DESCRIPTION

This module allows to apply Moose::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.

It’s possible to to apply roles to <B>allB> actions of a controller without specifying the Does keyword in every action definition:



    package MyApp::Controller::Bar

    use Moose;
    use namespace::autoclean;

    BEGIN { extends Catalyst::Controller::ActionRole }

    __PACKAGE__->config(
        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.
    #
    # If MyApp::ActionRole::Bar exists and is loadable, it will be loaded,
    # but even if it doesnt exist Catalyst::ActionRole::Bar will not be loaded.
    sub moo : Local { ... }



Additionally, roles can be applied to selected actions without specifying Does using action in Catalyst::Controller and configured with action_args in Catalyst::Controller:



    package MyApp::Controller::Baz;

    use Moose;
    use namespace::autoclean;

    BEGIN { extends Catalyst::Controller::ActionRole }

    __PACKAGE__->config(
        action_roles => [qw( Foo )],
        action       => {
            some_action    => { Does => [qw( ~Bar )] },
            another_action => { Does => [qw( +MyActionRole::Baz )] },
        },
        action_args  => {
            another_action => { customarg => arg1 },
        }
    );

    # has Catalyst::ActionRole::Foo and MyApp::ActionRole::Bar applied
    sub some_action : Local { ... }

    # has Catalyst::ActionRole::Foo and MyActionRole::Baz applied
    # and associated action class would get additional arguments passed
    sub another_action : 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::ActionRole:: ]. 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 for Does will be performed.

METHODS

    gather_action_roles(\%action_args)

Gathers the list of roles to apply to an action with the given %action_args.

ROLE PREFIX SEARCHING

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.

AUTHORS

o Florian Ragwitz <rafl@debian.org>
o Hans Dieter Pearcey <hdp@weftsoar.net>
o Alex J. G. BurzyXski <ajgb@ajgb.net>
o John Napiorkowski <jjn1056@yahoo.com>
o William King <william.king@quentustech.com>
o Tomas Doran <bobtfish@bobtfish.net>

COPYRIGHT AND LICENSE

This software is copyright (c) 2010 by Florian Ragwitz.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Search for    or go to Top of page |  Section 3 |  Main Index


perl v5.20.3 CATALYST::CONTROLLER::ACTIONROLE (3) 2010-08-25

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.