X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;h=cff5fc3c97da6ed653ab56811e28d55dfeda6e2a;hp=d205492108f9a409ac6e09fe7967a964d7eb2027;hb=53c495ce524c95ee0fc1ee13f20edeeb382ef89f;hpb=b88483474b62665f14e3a3663be5bba38292a2d6 diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index d205492..cff5fc3 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -26,7 +26,7 @@ sub generate_constructor_method_inline { ... local $@; - # warn $code; + #warn $code; my $res = eval $code; die $@ if $@; $res; @@ -61,20 +61,20 @@ sub _generate_processattrs { } $code .= " \$attrs[$index]->verify_type_constraint_error( - '$key', \$value, \$attrs[$index]->type_constraint + q{$key}, \$value, \$attrs[$index]->type_constraint ) } "; } - $code .= "\$instance->{'$key'} = \$value;\n"; + $code .= "\$instance->{q{$key}} = \$value;\n"; if ($attr->is_weak_ref) { - $code .= "Scalar::Util::weaken( \$instance->{'$key'} ) if ref( \$value );\n"; + $code .= "Scalar::Util::weaken( \$instance->{q{$key}} ) if ref( \$value );\n"; } if ($attr->has_trigger) { - $code .= "\$attrs[$index]->{trigger}->( \$instance, \$value );\n"; + $code .= "push \@triggers, [\$attrs[$index]->{trigger}, \$value];\n"; } $code .= "\n} else {\n"; @@ -117,15 +117,15 @@ sub _generate_processattrs { if ($attr->has_type_constraint) { $code .= "{ unless (\$attrs[$index]->{type_constraint}->check(\$value)) { - \$attrs[$index]->verify_type_constraint_error('$key', \$value, \$attrs[$index]->type_constraint) + \$attrs[$index]->verify_type_constraint_error(q{$key}, \$value, \$attrs[$index]->type_constraint) } }"; } - $code .= "\$instance->{'$key'} = \$value;\n"; + $code .= "\$instance->{q{$key}} = \$value;\n"; if ($attr->is_weak_ref) { - $code .= "Scalar::Util::weaken( \$instance->{'$key'} ) if ref( \$value );\n"; + $code .= "Scalar::Util::weaken( \$instance->{q{$key}} ) if ref( \$value );\n"; } } } @@ -138,7 +138,7 @@ sub _generate_processattrs { push @res, $code; } - return join "\n", @res; + return join "\n", q{my @triggers;}, @res, q{$_->[0]->($instance, $_->[1]) for @triggers;}; } sub _generate_BUILDARGS {