Created
November 5, 2013 23:39
-
-
Save tobyink/7328339 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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