Created
April 27, 2009 07:00
-
-
Save ocharles/102367 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
package A; | |
use Moose::Role; | |
sub do_a { print "doing a in A\n" } | |
package B; | |
use Moose::Role; | |
sub do_b { print "doing b in B\n" } | |
package C; | |
use Moose::Role; | |
# Role composition - bigger roles from smaller roles | |
with "A", "B"; | |
sub do_composed { print "composed in C\n" } | |
package D; | |
use Moose::Role; | |
sub over { print "override me in D\n" } | |
package E; | |
use Moose::Role; | |
with "D"; | |
around "over" => sub { print "overridden in E\n" }; | |
package G; | |
# Alternatively to around: | |
with "D" => { excludes => 'over' }; | |
sub over { "In G" } | |
package F; | |
use Moose; | |
with "E"; | |
sub do_b { print "do_b called from F\n" } | |
package Client; | |
my $f = F->new; | |
$f->do_a; | |
$f->do_b; | |
$f->do_composed; | |
$f->over; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment