in reply to Re5: Calling SUPER in MethodMaker-generated methods
in thread Calling SUPER in MethodMaker-generated methods
Done! For the record, I attached the final MethodMaker-derived code. Would you accept a small tip via PayPal (if so, what e-mail should I use)?
I'm going to see about submitting this for the MethodMaker maintainer.
-Dan#################################################################### ## CustomMethodMaker #################################################################### package CustomMethodMaker; use base ( 'Class::MethodMaker' ); use Carp; =head2 grouped_fields_inherit Works like grouped_fields, except that it also calls the parent class. =cut sub grouped_fields_inherit { my ($class, %args) = @_; my %methods; foreach (keys %args) { my @slots = @{$args{$_}}; $class->get_set(@slots); my $method_name = $_; my $caller = $class->find_target_class(); $methods{$_} = sub { my ( $self ) = @_; my @parent_slots = (); my $to_execute = "SUPER::$method_name"; # # Without $caller and eval, the following line causes this err +or: # # Can't locate auto/CustomMethodMaker/SUPER/[METHOD].al in @ +INC # @parent_slots = eval "package $caller; return \$self->SUPER::$ +method_name(\@_); 1" or die $@; return ( @parent_slots, @slots ); }; } $class->install_methods(%methods); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re7: Calling SUPER in MethodMaker-generated methods
by bbfu (Curate) on Jul 09, 2003 at 15:15 UTC | |
by danb (Friar) on Jul 09, 2003 at 17:42 UTC | |
by bbfu (Curate) on Jul 13, 2003 at 18:46 UTC |