3

With the new Mason 2 introducing Moose method modifiers like around, augment, override, etc., I'd like to be able to start writing components that acted as Moose roles.

As far as I can tell, it's not supported out of the box, but has anyone tried extending Mason (through a plugin perhaps) to provide this functionality? In general, what would that entail, and is it even possible given the way Mason renders components?

edit: I've tried "faking" it using $m->visit('other component'), which seems to at least load the methods of the other component, but method modifiers seem to fail with: ...not found in the inheritance hierarchy

Ryan
  • 672
  • 1
  • 6
  • 16
  • 1
    You wouldn't get much help here for the Mason2. Probably Mason maintainers or power users hasn't subscribed the `mason` tag, what is unfortunate, because the SO is an very good platform for such "how-to" support. Try the [mason-users](http://sourceforge.net/p/mason/mailman/mason-users/) mailing-list with a bit better answer rate. – clt60 Jan 03 '15 at 09:55
  • Anyway, could you describe what you want achieve with Mason? Asking because each Mason component is an dynamically generated unique class what inherits from the `Mason::Component` using on the Mason inheritance chain, so probably here is way how to achieve you needs. Also, (if you want extend Mason) - here are the plugins infrastructure what are implemented as roles. – clt60 Jan 03 '15 at 10:23
  • Sorry for the late reply... I think the best way to describe my use case would be in the context of a table. For example, I would have a "table.mc" component that implemented a barebones table/tbody/row structure. Then maybe I would have a few "add-on" roles...a pager, a header, maybe a handful of different wrappers. These roles would hook into the base table class using method modifiers. Finally when I go to construct each *specific* instance of a table, I could simply inherit from "table.mc" and then mix and match the desired roles. – Ryan Mar 02 '15 at 04:11
  • Maybe not a perfect example, but I think that illustrates how someone may want to "build up" a component beyond what normal inheritance would provide. On your suggestion, I looked into the `Mason::Component` code, but I couldn't identify an easy way to tell Mason to `use Moose::Role` during construction, rather than `use Moose` – Ryan Mar 02 '15 at 04:15
  • 1
    Yeah, exactly this is what i missing from Mason2 too. (Or, dynamic inheritance, but the your _Roles_ idea is far better). As I said in my 1st comment, probably will be better to ask in the mailing-list (unfortunately, it is terrible for code formatting and so), but when you check Mason related questions here - you'll get the idea about the "helpful response rate". If you will get some solution, **please** share it here - maybe more questions/answers here will convince Jon (the author) to read the SO too. ;) – clt60 Mar 02 '15 at 14:14
  • I'll do exactly that, thank you for the suggestions! – Ryan Mar 02 '15 at 18:32

0 Answers0