Created
March 11, 2011 00:29
-
-
Save mstratman/865253 to your computer and use it in GitHub Desktop.
Delegation example from http://blogs.perl.org/users/mark_a_stratman/2011/03/subclassing-tricky-non-moose-classes-dont-do-it.html
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 MyDate; | |
use Moose; | |
use namespace::autoclean; | |
use Date::Handler; | |
has '_date_handler' => ( | |
is => 'ro', | |
isa => 'Date::Handler', | |
handles => qr/.*/, | |
); | |
around BUILDARGS => sub { | |
my $orig = shift; | |
my $class = shift; | |
return $class->$orig(_date_handler => Date::Handler->new(@_)); | |
}; | |
no Moose; | |
__PACKAGE__->meta->make_immutable; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment