I'm new to Moose. My most recent discovery (the hard way) is that if you have a BUILD method in your class, and also one in a role the class consumes, only the class BUILD gets invoked. Makes sense: it's an override like any other.
So how do I specify in my role processing that should occur when the class is instantiated? Well, I can hack my way around that with attribute builder methods, I suspect.
But I don't know how to (cleanly) do the same for DEMOLISH. Things that occur to me to try include:
Implicitly require that the class invokes the role's DEMOLISH processing. Too easy to forget to do.
'requires DEMOLISH', 'after DEMOLISH' in the role. That at least gets enforced. But it's an additional constraint on the class.
Turn the role into a class, and make the old class a subclass of it. Works in some situations, but not in others.
You get the idea: I want the role to quietly do its thing without imposing its will on the class which consumes it.
TIA for any ideas.
In reply to BUILD in Moose role by Dinosaur
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |