Created
December 13, 2011 10:36
-
-
Save ranguard/1471606 to your computer and use it in GitHub Desktop.
MooseX::ClassAttribute bug/feature?
This file contains hidden or 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 My::Base; | |
| use Moose; | |
| use MooseX::ClassAttribute; | |
| class_has 'foo' => | |
| ( is => 'rw', | |
| isa => 'Str', | |
| lazy_build => 1, | |
| ); | |
| sub _build_foo { die "setup in child" }; | |
| __PACKAGE__->meta()->make_immutable(); | |
| no Moose; | |
| no MooseX::ClassAttribute; | |
| package My::A; | |
| use Moose; | |
| use MooseX::ClassAttribute; | |
| extends 'My::Base'; | |
| override '_build_foo' => sub { return 'a' }; | |
| package My::B; | |
| use Moose; | |
| use MooseX::ClassAttribute; | |
| extends 'My::Base'; | |
| override '_build_foo' => sub { return 'b' }; | |
| package main; | |
| my $a = My::A->new(); | |
| my $b = My::B->new(); | |
| print "A -> " . $a->foo() . "\n"; | |
| print "B -> " . $b->foo() . "\n"; | |
| -------- | |
| >perl test.pl | |
| A -> a | |
| B -> a | |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Moose version 2.0008
MooseX::ClassAttribute version 0.26