On Wed, Jul 27, 2011 at 9:29 AM, Steve <[email protected]> wrote: > Hi all, > > I have a question regarding controller refactoring, and whether subclassing > (or adding a Moose role) would be a good idea for a particular application. > > The application creates 6 different types of invoices, each representing a > particular type of service. Currently, I have a controller for each that > handles the various steps that must be taken to produce and ultimately send > these invoices. ALL OF THESE CONTROLLERS HAVE THE SAME ACTIONS, and most of > the same logic, which to me says I should refactor these controllers...I
That is what Action Classes are for: Look for Action classes in: perldoc Catalyst::Manual::ExtendingCatalyst > just don't know how, and also whether the benefit is worth the work. Almost > certainly it would not be worth it in and of itself, however I might want to > write another application someday where knowing this would certainly be > useful :) > You can also make a base controller type and inherit from that. Remember that Catalyst is built over Moose so everytihng Moose you can do with Catalyst. > So IF this seems reasonable, and my controllers are 'FOOcontrol', > 'BARcontrol', 'BAZcontrol', and my actions are 'initialize', 'upload_data', > 'process', 'generate_invoices'...etc., what is a good way to stay DRY? In > particular I'm having a hard time wrapping my mind around how the URI's > would be handled. > Action classes and default methods on your root controller. -- Alejandro Imass > Thanks, > Steve > > _______________________________________________ > List: [email protected] > Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst > Searchable archive: http://www.mail-archive.com/[email protected]/ > Dev site: http://dev.catalyst.perl.org/ > _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
