|Pathologically Eclectic Rubbish Lister|
How to add TO_JSON base method for DBIC Result in Catalystby Solo (Deacon)
|on Aug 20, 2011 at 15:16 UTC||Need Help??|
Solo has asked for the wisdom of the Perl Monks concerning the following question:
It's difficult for me to title this question, because I'm not sure which Catalyst magic I'm breaking. I'm new to Catalyst and Moose and lost in all the pod.
I'm trying to add generic JSON support to a Catalyst model. To do so, I add a TO_JSON object to my result class(es):
and extend Catalyst::View::JSON with some code I found. (I've stumbled on different approaches since--opinions on best approach for this also welcomed):
This works for each result class individually, but I'd like it to be DRYer. So, I think to create a result base class and extend that for my result classes...
Catalyst doesn't like this approach, yet, and I'm having a hard time figuring out which doc to read.
Do I just need to tell Catalyst to ignore the '...::Base' class when loading namespaces (or whatever)?
Or should I be doing this some other way entirely?