Test for init_arg => undef
[gitmo/Mouse.git] / lib / Mouse / Meta / Method / Constructor.pm
index 7568dcd..83bf3ef 100644 (file)
@@ -5,7 +5,7 @@ use warnings;
 sub generate_constructor_method_inline {
     my ($class, $meta) = @_;
 
-    my @attrs = $meta->compute_all_applicable_attributes; # this one is using by evaled code
+    my @attrs = $meta->compute_all_applicable_attributes;
     my $buildall = $class->_generate_BUILDALL($meta);
     my $buildargs = $class->_generate_BUILDARGS();
     my $processattrs = $class->_generate_processattrs($meta, \@attrs);
@@ -21,8 +21,6 @@ sub generate_constructor_method_inline {
     }
 ...
 
-    warn $code if $ENV{DEBUG};
-
     local $@;
     my $res = eval $code;
     die $@ if $@;
@@ -55,7 +53,7 @@ sub _generate_processattrs {
             push @code, "\$instance->{'$key'} = \$value;";
 
             if ($attr->is_weak_ref) {
-                push @code, "weaken( \$instance->{'$key'} ) if ref( \$value );";
+                push @code, "Scalar::Util::weaken( \$instance->{'$key'} ) if ref( \$value );";
             }
 
             if ( $attr->has_trigger ) {
@@ -109,7 +107,7 @@ sub _generate_processattrs {
                     push @code, "\$instance->{'$key'} = \$value;";
 
                     if ($attr->is_weak_ref) {
-                        push @code, "weaken( \$instance->{'$key'} ) if ref( \$value );";
+                        push @code, "Scalar::Util::weaken( \$instance->{'$key'} ) if ref( \$value );";
                     }
                 }
                 join "\n", @code;