X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;h=11bc7e5d52b933ad461ac9d5f4598abe0fe1fb12;hb=f262f14e4f739820c2a6d43b63041c68cf411774;hp=c0cf03e9c43f3e094d552a5c0dc6725a7096eeb0;hpb=e8ba7b267968d4ca0e94d03276ca4c33fed40482;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index c0cf03e..11bc7e5 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -37,13 +37,14 @@ sub _generate_processattrs { my $from = $attr->init_arg; my $key = $attr->name; - my $part1 = do { + my $set_value = do { my @code; - push @code, "my \$value = \$args->{'$from'};"; - if ($attr->should_coerce) { - push @code, "\$value = \$attr->coerce_constraint( \$value );"; + push @code, "my \$value = \$attr->coerce_constraint( \$args->{'$from'});"; + } + else { + push @code, "my \$value = \$args->{'$from'};"; } if ($attr->has_type_constraint) { @@ -63,7 +64,7 @@ sub _generate_processattrs { join "\n", @code; }; - my $part2 = do { + my $make_default_value = do { my @code; if ( $attr->has_default || $attr->has_builder ) { @@ -118,9 +119,9 @@ sub _generate_processattrs { { my \$attr = \$attrs[$index]; if (exists(\$args->{'$from'})) { - $part1; + $set_value; } else { - $part2; + $make_default_value; } } ...