X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;h=4c22fd8f7b017fb62e94b65cd6f451d992b38fe6;hb=c91d12e031bd905978b1e664df94fc41bc647d34;hp=8b3f3a17f905f8e2b085715f02f4b49fd4d61294;hpb=88b6c018ca804f12a431dacf12bb52d0df169e4c;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index 8b3f3a1..4c22fd8 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -50,8 +50,7 @@ sub _generate_processattrs { if ($attr->has_type_constraint) { $code .= "{ - local \$_ = \$value; - unless (\$attrs[$index]->{find_type_constraint}->(\$_)) { + unless (\$attrs[$index]->{find_type_constraint}->(\$value)) { \$attrs[$index]->verify_type_constraint_error('$key', \$_, \$attrs[$index]->type_constraint) } }"; @@ -106,8 +105,7 @@ sub _generate_processattrs { if ($attr->has_type_constraint) { $code .= "{ - local \$_ = \$value; - unless (\$attrs[$index]->{find_type_constraint}->(\$_)) { + unless (\$attrs[$index]->{find_type_constraint}->(\$value)) { \$attrs[$index]->verify_type_constraint_error('$key', \$_, \$attrs[$index]->type_constraint) } }"; @@ -143,14 +141,9 @@ sub _generate_BUILDARGS { return <<'...'; do { if ( scalar @_ == 1 ) { - if ( defined $_[0] ) { - ( ref( $_[0] ) eq 'HASH' ) + ( ref( $_[0] ) eq 'HASH' ) || Carp::confess "Single parameters to new() must be a HASH ref"; - +{ %{ $_[0] } }; - } - else { - +{}; - } + +{ %{ $_[0] } }; } else { +{@_};