BUILD if I recall is called on every class in the inheritance chain so you would only need it set once to get this behavior.
------Original Message------ From: Yuri Shtil To: Yuval Kogman Cc: moose@perl.org Sent: Oct 20, 2008 6:23 PM Subject: Re: How to call post-constructor automatically Yuval Kogman wrote: > On Thu, Oct 16, 2008 at 14:38:37 -0700, Yuri Shtil wrote: > > >> The trick is I want the method be called implicitly as a part of new. >> It is almost as having a hidden subclass of Two with a call to >> post_constructor in its BUILD method. >> > > I think this is exactly what you want, > > sub BUILD { > shift->post_constructor; > } > > in Two will work as you expect. > > That will be called even if a subclass adds another BUILD method, > but of course 'post_constructor' will be overridable normally (i'm > guessing that's why you don't want to just use BUILD?). > > Thank you Yuval, However I want to avoid putting the call into each BUILD that is the last in the hierarchy. If I decide to subclass from Two, I have to move the call manually. The idea behind my question is to be able to check if all constructors worked "correctly", for example consumed all named parameters. -- Yuri Sent via BlackBerry from T-Mobile