in reply to blessed confusion
Moose (I know, but hold on) separates object creation from object initialization. When you construct a new Moose object, its constructor calls for you a method (BUILDALL, I believe but haven't confirmed before posting) which calls every BUILD method in the appropriate class hierarchy. Each BUILD method performs the appropriate initialization.
bless only occurs once.
If you can't migrate to Moose right now, you could do something similar. Move the responsibility for blessing an object into the parentmost new and create an initialize() method in each class where that's useful. Within new, after blessing, call initialize. Be sure to call the parent implementation:
sub initialize { my $self = shift; $self->SUPER::initialize( @_ ); ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: blessed confusion
by perl-diddler (Chaplain) on Sep 09, 2010 at 02:42 UTC | |
by chromatic (Archbishop) on Sep 09, 2010 at 06:06 UTC | |
by ikegami (Patriarch) on Sep 09, 2010 at 02:51 UTC |