X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FTypeConstraint.pm;h=dfb933706829a77d14f191994868f17bde059f34;hb=c06ab42929c96053e941120f1469aeee65e63149;hp=50473fac21bdb832c21572e0a180c6ef4366ddcd;hpb=fdef448eeca7cc251e2fbb53a141919add2bd306;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 50473fa..dfb9337 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -1,9 +1,11 @@ package Mouse::Meta::TypeConstraint; use Mouse::Util qw(:meta); # enables strict and warnings +use Scalar::Util (); use overload 'bool' => sub (){ 1 }, # always true '""' => sub { $_[0]->name }, # stringify to tc name + '0+' => sub { Scalar::Util::refaddr($_[0]) }, '|' => sub { # or-combination require Mouse::Util::TypeConstraints; return Mouse::Util::TypeConstraints::find_or_parse_type_constraint( @@ -14,7 +16,8 @@ use overload fallback => 1; sub new { - my($class, %args) = @_; + my $class = shift; + my %args = @_ == 1 ? %{$_[0]} : @_; $args{name} = '__ANON__' if !defined $args{name}; @@ -164,7 +167,7 @@ sub get_message { } else { $value = ( defined $value ? overload::StrVal($value) : 'undef' ); - return "Validation failed for '$self' failed with value $value"; + return "Validation failed for '$self' with value $value"; } } @@ -236,7 +239,7 @@ Mouse::Meta::TypeConstraint - The Mouse Type Constraint metaclass =head1 VERSION -This document describes Mouse version 0.52 +This document describes Mouse version 0.66 =head1 DESCRIPTION