-
-
Save nicomen/86238525ea5520000ecf61b290b45b72 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 MyApp::Base; | |
use Moose; | |
has 'abc' => ( is => 'ro', lazy => 1, default => 'def', reader => 'get_abc' ); | |
has 'xyz' => ( is => 'ro', lazy => 1, default => 123, reader => 'get_xyz' ); | |
around [qw/get_abc get_xyz/] => sub { | |
my ($orig, $self) = shift; | |
return "base: " . $self->$orig; | |
}; | |
package MyApp::Obj; | |
use Moose; | |
extends 'MyApp::Base'; | |
around [qw/get_abc get_xyz/] => sub { | |
my ($orig, $self) = shift; | |
return "child: " . $self->$orig; | |
}; | |
package main; | |
my $o = MyApp::Obj->new(); | |
print "abc = " . $o->get_abc() . "\n"; | |
print "xyz = " . $o->get_xyz() . "\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment