in reply to Moose - two augmented methods in one class
I don't really have any opinion on whether or not you should be doing this, but...
package C1; use Moose; sub html { my $this = shift; return '<html>' . $this->head . '<body>' . inner() . '</body>' . '</html>'; } sub head { my $self = shift; my $child_implementation = $self->meta->get_method('head'); my $has_child_implementation = blessed($child_implementation) && $child_implementation->isa('Moose::Meta::Method::Augmented' +); return '<head>' . ($has_child_implementation ? inner() : '') . '</ +head>'; } package C2; use Moose; extends 'C1'; augment html => sub { return 'C2'; }; package main; warn C2->new->html;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Moose - two augmented methods in one class
by tobyink (Canon) on Jan 09, 2012 at 15:19 UTC | |
Re^2: Moose - two augmented methods in one class
by zwon (Abbot) on Jan 09, 2012 at 15:25 UTC | |
by tobyink (Canon) on Jan 09, 2012 at 15:37 UTC | |
by tobyink (Canon) on Jan 09, 2012 at 16:13 UTC | |
by stvn (Monsignor) on Jan 11, 2012 at 05:19 UTC | |
by tobyink (Canon) on Jan 11, 2012 at 12:04 UTC | |
|