[Catalyst] RFC: Reusable actions

Sebastian Riedel sri at oook.de
Thu Apr 6 14:34:26 CEST 2006


06.04.2006 14:00 Yuval Kogman:
> However, i don't see how this is much different than using
> controller base classes like DefaultEnd, especially if something
> like Moose is used to provide 'before' and 'after' at the "class"
> level?

It is not *much* different, just more Catalyst-ish.
before and after are most likely placeholders and will be replaced  
later,
you will be able to overload individual steps like validation and  
subclass other reusable actions.

Controller base classes are supposed to contain multiple actions,  
while "reusable actions" are just single actions.

DefaultEnd is a plugin, and can be converted to a reusable action class.


     package Catalyst::Action::Add;

     use base 'Catalyst::Action';

     sub do_stuff {
         my ( $self, $c ) = @_;

         # add new record to model

     }

     1;



     package Catalyst::Action::Add::WithValidation;

     use base 'Catalyst::Action::Add';

     sub validate {
         my ( $self, $c ) = @_;

         # validate params

     }

     1;


MOOSE!!!

--
sebastian




More information about the Catalyst mailing list