Created
April 27, 2009 16:56
-
-
Save ocharles/102594 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 feature 'say'; | |
package Load; | |
use Moose::Role; | |
sub load { say 'wee, loading' } | |
package CachedLoad; | |
use Moose::Role; | |
with 'Load'; | |
around 'load' => sub { | |
my ($orig, $self) = @_; | |
say 'cache first!'; | |
$self->$orig; | |
}; | |
package ConcreteDb; | |
use Moose; | |
with 'Load'; | |
package ConcreteCache; | |
use Moose; | |
with 'CachedLoad'; | |
package App; | |
my $db = ConcreteDb->new; | |
my $ca = ConcreteCache->new; | |
say "Load db:"; | |
$db->load; | |
say "load cache"; | |
$ca->load; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment