X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint.pm;h=ad5094bdeca0c21c40990253a08b5a33af12753d;hb=45fd4af3f6e105226269374597a182f1b2767131;hp=691337c096e36f1c1e6da07b007d26afd6f35116;hpb=b644e331bf70b87de226f1e228257d5ea1f4043c;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 691337c..ad5094b 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -12,7 +12,7 @@ use Sub::Name 'subname'; use Carp 'confess'; use Scalar::Util 'blessed'; -our $VERSION = '0.10'; +our $VERSION = '0.11'; our $AUTHORITY = 'cpan:STEVAN'; __PACKAGE__->meta->add_attribute('name' => (reader => 'name')); @@ -58,7 +58,7 @@ sub new { } sub coerce { ((shift)->coercion || confess "Cannot coerce without a type coercion")->coerce(@_) } -sub check { $_[0]->_compiled_type_constraint->($_[1]) } +sub check { $_[0]->_compiled_type_constraint->($_[1]) ? 1 : undef } sub validate { my ($self, $value) = @_; if ($self->_compiled_type_constraint->($value)) { @@ -124,11 +124,9 @@ sub _compile_hand_optimized_type_constraint { my $type_constraint = $self->hand_optimized_type_constraint; - return sub { - confess unless ref $type_constraint; - return undef unless $type_constraint->($_[0]); - return 1; - }; + confess unless ref $type_constraint; + + return $type_constraint; } sub _compile_subtype {