Created
March 17, 2009 08:56
-
-
Save omega/80411 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
#!/usr/bin/perl -w | |
package Role; | |
use Moose::Role; | |
has '_default_rows' => (is => 'rw', isa => 'Int'); | |
after 'BUILD' => sub { | |
my $self = shift; | |
$self->_default_rows($self->rows); | |
}; | |
sub BUILD {} | |
1; | |
package BaseClass; | |
use Moose; | |
with 'Role'; | |
has 'rows' => (is => 'rw', isa => 'Int', default => 10); | |
1; | |
package MyClass; | |
use Moose; | |
extends 'BaseClass'; | |
sub BUILD {}; | |
1; | |
package main; | |
use strict; | |
use Test::More tests => 4; | |
my $o = MyClass->new(); | |
is($o->rows, 10); | |
is($o->_default_rows, 10); | |
my $b = BaseClass->new(rows => 1); | |
is($b->rows, 1); | |
is($b->_default_rows, 1); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment