[Catalyst] How to avoid repeating methods in controllers ?

Alexander Hartmaier alexander.hartmaier at t-systems.at
Wed Jul 17 08:14:18 GMT 2013


Hi,
generally if you have some classes that have a common number of attributes =
and/or methods you'd move those in a base class or in more recent time cons=
truct it out of roles which are like lego blocks.

For your specific case https://metacpan.org/module/CatalystX::Resource look=
s to be the solution you are looking for.

BR Alex

On 2013-07-17 04:05, cc loo 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/C=
atalyst-Manual-5.9007/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#Refacto=
r_to_Use_a_'base'_Method_to_Start_the_Chains<http://search.cpan.org/%7Eethe=
r/Catalyst-Manual-5.9007/lib/Catalyst/Manual/Tutorial/04_BasicCRUD.pod#Refa=
ctor_to_Use_a_%27base%27_Method_to_Start_the_Chains>


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/p=
aste on every controller i have ?




_______________________________________________
List: Catalyst at lists.scsys.co.uk<mailto: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/




*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
T-Systems Austria GesmbH Rennweg 97-99, 1030 Wien
Handelsgericht Wien, FN 79340b
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
Notice: This e-mail contains information that is confidential and may be pr=
ivileged.
If you are not the intended recipient, please notify the sender and then
delete this e-mail immediately.
*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*"*=
"*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20130717/e8881=
6f5/attachment.htm


More information about the Catalyst mailing list