Fellow Monks,
How does one go to extend a base class that's implemented by means of a closure?
I have a base class in which the constructor initializes three fields
# constructor sub new { my $class = shift; my $self = { NAME => undef, ADDRESS => undef, PHONE => undef, }; my $closure = sub { my $field = shift; if (@_) { $self->{$field} = shift; } return $self->{$field}; }; bless( $closure, $class ); return $closure; }
I'd like to extend this class and add two more fields:
# constructor sub new { my $class = shift; my $self = { CELLULAR => undef, EMAIL => undef, }; my $closure = sub { my $field = shift; if (@_) { $self->{$field} = shift; } return $self->{$field}; }; bless( $closure, $class ); return $closure; }
How do I make the extended class call the constructor of the base class and make sure that the two new fields are added at the same time?
I searched but couldn't find any documentation about this, not on perl monks, not on google :(
In reply to OO: extending a closure object by gargle
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |