X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint.pm;h=f83d5df09f94e8a11404632d36b81b9d08688360;hb=856e64d4108c5faf3ba9ead64d73dbf53022541d;hp=559ef20fe2a4d5dcac1342ee8b53cdea64d87fa2;hpb=886179b3451716d1e87a393ce43536e6b3c21e36;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint.pm b/lib/Moose/Meta/TypeConstraint.pm index 559ef20..f83d5df 100644 --- a/lib/Moose/Meta/TypeConstraint.pm +++ b/lib/Moose/Meta/TypeConstraint.pm @@ -9,10 +9,11 @@ use overload '""' => sub { shift->name }, # stringify to tc name fallback => 1; use Scalar::Util qw(blessed refaddr); +use Sub::Name qw(subname); use base qw(Class::MOP::Object); -our $VERSION = '0.75_01'; +our $VERSION = '0.80'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -110,9 +111,9 @@ sub get_message { return $msg->($value); } else { - $value = (defined $value ? overload::StrVal($value) : 'undef'); + $value = (defined $value ? overload::StrVal($value) : 'undef'); return "Validation failed for '" . $self->name . "' failed with value $value"; - } + } } ## type predicates ... @@ -234,7 +235,7 @@ sub _compile_subtype { if ( $check == $null_constraint ) { return $optimized_parent; } else { - return Class::MOP::subname($self->name, sub { + return subname($self->name, sub { return undef unless $optimized_parent->($_[0]); my (@args) = @_; local $_ = $args[0]; @@ -245,7 +246,7 @@ sub _compile_subtype { # general case, check all the constraints, from the first parent to ourselves my @checks = @parents; push @checks, $check if $check != $null_constraint; - return Class::MOP::subname($self->name => sub { + return subname($self->name => sub { my (@args) = @_; local $_ = $args[0]; foreach my $check (@checks) { @@ -261,7 +262,7 @@ sub _compile_type { return $check if $check == $null_constraint; # Item, Any - return Class::MOP::subname($self->name => sub { + return subname($self->name => sub { my (@args) = @_; local $_ = $args[0]; $check->(@args);