Skip to content

Instantly share code, notes, and snippets.

@nicomen
Forked from simonamor/test_fn.pl
Created September 12, 2016 11:52
Show Gist options
  • Save nicomen/86238525ea5520000ecf61b290b45b72 to your computer and use it in GitHub Desktop.
Save nicomen/86238525ea5520000ecf61b290b45b72 to your computer and use it in GitHub Desktop.
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