X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FMethod%2FConstructor.pm;h=98a64298c418deeaf568003fe5bf9da6df85eba9;hb=983d58a5ea543a21c48cb04311883f1b36de1874;hp=e539955c637bb8eebffd1f995a73c054deb8e1c0;hpb=32ec255c44d36d63cce20f5e21386d5cd11396b9;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index e539955..98a6429 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -1,7 +1,7 @@ package Mouse::Meta::Method::Constructor; use Mouse::Util qw(:meta); # enables strict and warnings -use constant _MOUSE_DEBUG => !!$ENV{MOUSE_DEBUG}; +use constant _MOUSE_DEBUG => $ENV{MOUSE_DEBUG} ? 1 : 0; sub _inline_slot{ my(undef, $self_var, $attr_name) = @_; @@ -87,10 +87,6 @@ sub _generate_initialize_object { $post_process .= "\$checks[$index]->($instance_slot)\n"; $post_process .= " or $attr_var->_throw_type_constraint_error($instance_slot, $constraint_var);\n"; } - if($is_weak_ref){ - $post_process = "Scalar::Util::weaken($instance_slot) " - . "if ref $instance_slot;\n"; - } # build cde for an attribute if (defined $init_arg) { @@ -151,6 +147,11 @@ sub _generate_initialize_object { $code .= "}\n" if defined $init_arg; + if($is_weak_ref){ + $code .= "Scalar::Util::weaken($instance_slot) " + . "if ref $instance_slot;\n"; + } + push @res, $code; } @@ -232,7 +233,7 @@ Mouse::Meta::Method::Constructor - A Mouse method generator for constructors =head1 VERSION -This document describes Mouse version 0.75 +This document describes Mouse version 0.94 =head1 SEE ALSO