Subject: | MooseX::Types does not play nice with MooseX::AttributeHelpers |
Given the two following library:
__MyLib.pm__
package MyLib;
use MooseX::Types -declare => [ qw(PositiveInt) ];
use MooseX::Types::Moose qw( Int );
subtype PositiveInt,
as Int,
where { $_ >= 0 },
message { "Value $_ must be a positive integer or zero"; };
1;
__End of MyLib.pm__
and this main:
package Foo;
use lib '.';
use Moose;
use MooseX::AttributeHelpers;
use MyLib qw(:all);
has 'bar' => ( isa => PositiveInt,
is => 'ro',
writer => 'set_bar',
default => 'default' );
has foo => (
metaclass => 'Collection::Array',
is => 'ro', isa => 'ArrayRef[PositiveInt]',
init_arg => undef, default => sub { []; }, lazy => 1,
provides => {
'set' => 'set_foo',
'get' => 'get_foo',
},
);
no Moose;
__PACKAGE__->meta->make_immutable;
package main;
my $x = Foo->new( bar => 1 );
print "Foo->bar is ".$x->bar()."\n";
$x->set_foo(1,1);
the method "set_foo" will fail this way:
Value 1 did not pass container type constraint 'PositiveInt' at
/usr/local/lib/perl5/site_perl/5.8.9/MooseX/AttributeHelpers/MethodProvider/Array.pm
line 77
Foo::set_foo('Foo=HASH(0x28c3db28)', 1, 1) called at ./mt4 line 33
Here is other pertinent information:
Show quoted text
> uname -rs
FreeBSD 7.2-RELEASE-p1
Show quoted text> perl -v
This is perl, v5.8.9 built for i386-freebsd-thread-multi-64int
(with 1 registered patch, see perl -V for more detail)