From: Shawn M Moore Date: Wed, 16 Jul 2008 05:49:38 +0000 (+0000) Subject: Some simplification of the inlined type check X-Git-Tag: 0.19~250 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=d0566009e6a9eee9a27c21261f00915f9737a33e Some simplification of the inlined type check --- 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} = $_;';