[Catalyst] Catalyst action attributes

Toby Corkindale toby.corkindale at strategicdata.com.au
Mon Jul 13 06:27:19 GMT 2009


Toby Corkindale wrote:
> Hi,
> I wondered if anyone could point me towards a working example of 
> creating custom action attribute handlers for Catalyst?
> 
> eg. The contents of Catalyst::Controller::SecretAgent in the example below:
> 
> 
> package MyApp::Controller::M;
> use parent 'Catalyst::Controller::SecretAgent';
> # Provides Vehicle() and Gimmick() actions.
> 
> sub bond : Vehicle('Aston Martin') {
>   my ($self, $c) = @_;
>   # ...
> }
> 
> sub maxwell_smart : Gimmick('Shoe-phone') {
>   My ($self, $c) = @_;
>   #...
> }
> 
> 1;


I should clarify what I'm after..
I'd still like to be able to specify regular DispatchType attributes 
against the routines (eg. Local, Chained, etc), but I'd also like to 
have my own methods called against the other attributes I've specified.

The first method I tried was:
   package Catalyst::Controller::SecretAgent;
   use strict / use warnings
   use parent 'Catalyst::Controller';
   use attributes __PACKAGE__ => \&set_vehicle, "Vehicle";
   sub set_vehicle { # do something }
   ...

but I think that messes up catalyst's own handling of attributes.



More information about the Catalyst mailing list