Skip to content

Instantly share code, notes, and snippets.

@ocharles
Created April 27, 2009 16:56
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 ocharles/102594 to your computer and use it in GitHub Desktop.
Save ocharles/102594 to your computer and use it in GitHub Desktop.
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