On Wed, 11 Feb 2009, Oliver Charles wrote:

On Wed, Feb 11, 2009 at 7:01 PM, Dave Rolsky <auta...@urth.org> wrote:
You want to use augment/inner, I think.

See
http://search.cpan.org/~drolsky/Moose-0.68/lib/Moose/Cookbook/Basics/Recipe6.pod
and
http://search.cpan.org/~drolsky/Moose-0.68/lib/Moose/Manual/MethodModifiers.pod#INNER_AND_AUGMENT

Actually, I think Jonathan is looking for inner and augment but the
other way round... Augment works on the subclass, but Jonathan needs
to run it in the superclass. I ran into just this problem, and ended
up going with the "sub foo" and "sub _do_foo" approach, but it's not
the nicest solution.

This is _exactly what augment/inner is for!

 package Parent;

 sub foo {
     my $self = shift;

     $self->wrapper_part1();
     inner();
     $self->wrapper_part2();
 }


 package Child;

 extends 'Parent';

 augment 'foo' => sub {
     my $self = shift;

     $self->fill_in_the_middle();
 };


-dave

/*============================================================
http://VegGuide.org               http://blog.urth.org
Your guide to all that's veg      House Absolute(ly Pointless)
============================================================*/

Reply via email to