From: Ricardo SIGNES Date: Wed, 21 Jan 2009 23:04:09 +0000 (+0000) Subject: regsiter maybe_type X-Git-Tag: 0.65~14 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=28ce144411ed03772a94621162187ef9a198bc49;p=gitmo%2FMoose.git regsiter maybe_type --- diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index aa9da35..b9af74e 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -305,14 +305,16 @@ sub role_type ($;$) { sub maybe_type { my ($type_parameter) = @_; - Moose::Meta::TypeConstraint->new( - parent => find_type_constraint('Item'), - constraint => sub { - my $check = $type_parameter->_compiled_type_constraint; - return 1 if not(defined($_)) || $check->($_); - return; - } - ) + register_type_constraint( + Moose::Meta::TypeConstraint->new( + parent => find_type_constraint('Item'), + constraint => sub { + my $check = $type_parameter->_compiled_type_constraint; + return 1 if not(defined($_)) || $check->($_); + return; + } + ) + ); } sub coerce {