composing your own behavior across Moose class structures
In my last entry, I wrote about how role composition and advice and BUILD
interact. A number
of times, Iโve wanted to get behavior that was like BUILD
, but without
needing the stub method hacks that are needed to get roles to participate in
the method call. A very simple example came when I was writing
Throwable::X, which had a
mechanism for all of its contituent parts to contribute tags. The idea was
that any class or role that was part of your class hierarchy could implement an
x_tags
method that would return a list of tag strings. These methods would
all get called and the resulting set of tags would be uniqued and returned.