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=e2a3b7ca6c13b5397f96cc18c194849a681a7e9f;hp=2e848a75ed6ff061144dd08d6d944615dacac548;hb=f7e41edaceee0d549a2d664378cfcf85dcf9454b;hpb=1e5823974a557bd35b4aa4a5c1d1aecf1e5483d2 diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index 2e848a7..e2a3b7c 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -60,6 +60,7 @@ sub _generate_processattrs { my $init_arg = $attr->init_arg; my $type_constraint = $attr->type_constraint; + my $is_weak_ref = $attr->is_weak_ref; my $need_coercion; my $instance_slot = $method_class->_inline_slot('$instance', $key); @@ -78,7 +79,7 @@ sub _generate_processattrs { $post_process .= "\$checks[$index]->($instance_slot)"; $post_process .= " or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n"; } - if($attr->is_weak_ref){ + if($is_weak_ref){ $post_process .= "Scalar::Util::weaken($instance_slot) if ref $instance_slot;\n"; } @@ -126,6 +127,9 @@ sub _generate_processattrs { } $code .= "$instance_slot = $value;\n"; + if($is_weak_ref){ + $code .= "Scalar::Util::weaken($instance_slot);\n"; + } } } elsif ($attr->is_required) { @@ -193,7 +197,7 @@ Mouse::Meta::Method::Constructor - A Mouse method generator for constructors =head1 VERSION -This document describes Mouse version 0.40_06 +This document describes Mouse version 0.40_08 =head1 SEE ALSO