X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FAttribute.pm;h=ef50e056de9731c75d0244d249731fd4a68ae16e;hb=d0566009e6a9eee9a27c21261f00915f9737a33e;hp=4bdb9f8167b0077ac8a323b9b883fc8c2d2d34f0;hpb=cbdd0fa406d4f9d23a0d6a17891daf995e4c84c5;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 4bdb9f8..ef50e05 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -84,10 +84,10 @@ sub generate_accessor { } if ($constraint) { - $accessor .= 'do { - my $display = defined($_) ? overload::StrVal($_) : "undef"; - Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display") unless $constraint->(); - };' + $accessor .= 'unless ($constraint->()) { + my $display = defined($_) ? overload::StrVal($_) : "undef"; + Carp::confess("Attribute ($name) does not pass the type constraint because: Validation failed for \'$type\' failed with value $display"); + }' } $accessor .= '$self->{$key} = $_;';