in reply to Re^3: Re-blessing || Re-constructing objects
in thread Re-blessing || Re-constructing objects
Those controlled manners are at least two:
three packages are used, but conceptually is just one class, so there is no messing with the internals of one class from another and the reblessing is always done from inside the class not from the outside.class TheHulk; sub new { bless $self, $class; $self->go_normal; $self; } sub go_normal { bless $self, TheHulk::_normal; } sub go_green { bless $self, TheHulk::_green; } sub relax {} sub make_angry {} package TheHulk::_normal; sub run { ... } sub make_angry { $self->go_green; } package TheHulk::_green; sub run { ... } sub relax { $self->go_normal; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Re-blessing || Re-constructing objects
by demerphq (Chancellor) on Apr 18, 2006 at 18:53 UTC | |
|
Re^5: Re-blessing || Re-constructing objects
by perrin (Chancellor) on Apr 18, 2006 at 18:53 UTC | |
by demerphq (Chancellor) on Apr 18, 2006 at 21:30 UTC | |
by salva (Canon) on Apr 18, 2006 at 19:03 UTC | |
by perrin (Chancellor) on Apr 18, 2006 at 19:45 UTC | |
by salva (Canon) on Apr 18, 2006 at 20:00 UTC |