Skip to content

Instantly share code, notes, and snippets.

@tobyink
Created November 5, 2013 23:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobyink/7328339 to your computer and use it in GitHub Desktop.
Save tobyink/7328339 to your computer and use it in GitHub Desktop.
use strict; use warnings;
package Child {
use Moose;
sub method_x { warn "call method_x" }
sub method_y { warn "call method_y" }
sub method_z { warn "call method_z" }
}
package Parent {
use Moose;
has child => (
is => 'rw',
handles => {
x => 'method_x',
y => 'method_y',
z => 'method_z',
}
);
# A method modifier in action
after [qw/ x y z /] => sub {
warn "called after every Parent (!) invocation";
};
}
my $p = Parent->new(child => Child->new);
$p->x; $p->y; $p->z;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment