[Catalyst] How to avoid repeating methods in controllers ?

Robert Rothenberg robrwo at gmail.com
Sun Jul 21 13:51:58 GMT 2013

I prefer to put as much code as I can (especially "business logic" code)
into Moose role methods. This makes it easier to share code among multiple
controller methods, and it makes the code a little easier to read as well
as test (since the role methods don't require the Catalyst server to be
running per se: the context can be simulated using

If the code really does require a controller, I create a base controller
class that uses configuration parameters from $self->{config}, and then
have the actual controllers use something like

    table =3D> 'foo',

On Wed, Jul 17, 2013 at 3:05 AM, cc loo <mobile.ccloo at gmail.com> wrote:

> Hi all, i'm a network engineer by trade and is picking up perl/catalyst to
> upgrade my skills :)
> I have a couple of controllers each having same methods, chaining off
> their respective 'base' methods.
> I build my controllers off this guide here:
> http://search.cpan.org/~ether/Catalyst-Manual-5.9007/lib/Catalyst/Manual/=
> So, i have
> controller_a with a method 'list' , chaining off 'base'
> controller_b with a method 'list', chaining off' 'base'
> Is there a more graceful manner of inheriting this method instead of
> copy/paste on every controller i have ?
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive:
> http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130721/23b3e=

More information about the Catalyst mailing list