Grokbase
Topics Posts Groups | in
x
[ help ]

Re: How to call post-constructor automatically

View PostFlat  Thread  Threaded | < Prev
Yuval Kogman Re: How to call post-constructor automatically
| +1 vote
[ Profile | Reply to group ] [ Flat  Thread  Threaded ]
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?).

--
  Yuval Kogman <nothingmuch@woobling.org>
http://nothingmuch.woobling.org 0xEBD27418

Thread : How to call post-constructor automatically
1)
Yuri Shtil Hi all, Let's assume we have a hierarchy of classes: package Top; use Moose; package One; use...
2)
Yuval Kogman I think this is exactly what you want, sub BUILD { shift->post_constructor; in Two will work as you...
spacer
View PostFlat  Thread  Threaded | < Prev