Skip to content

Instantly share code, notes, and snippets.

@mackee
Created March 27, 2013 02:37
Show Gist options
  • Save mackee/5251123 to your computer and use it in GitHub Desktop.
Save mackee/5251123 to your computer and use it in GitHub Desktop.
use strict;
use warnings;
use utf8;
use 5.10.1;
package Parent {
use Mouse;
no Mouse;
sub BUILD {
my ($self) = @_;
if (!defined $self->meta->{modifiers}{as_string}) {
$self->meta->add_around_method_modifier(as_string => sub {
my $orig = shift;
my $result = $orig->(@_);
return 'extended_'.$result;
});
}
}
sub as_string {
return "parent";
}
}
package Child {
use Mouse;
extends 'Parent';
no Mouse;
sub as_string {
return 'child';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment