package Mouse::Meta::Method::Constructor;
-use Mouse::Util qw(get_code_ref); # enables strict and warnings
+use Mouse::Util qw(:meta); # enables strict and warnings
sub _inline_slot{
my(undef, $self_var, $attr_name) = @_;
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);
$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";
}
}
$code .= "$instance_slot = $value;\n";
+ if($is_weak_ref){
+ $code .= "Scalar::Util::weaken($instance_slot);\n";
+ }
}
}
elsif ($attr->is_required) {
my @code;
for my $class ($metaclass->linearized_isa) {
- if (get_code_ref($class, 'BUILD')) {
+ if (Mouse::Util::get_code_ref($class, 'BUILD')) {
unshift @code, qq{${class}::BUILD(\$instance, \$args);};
}
}
=head1 VERSION
-This document describes Mouse version 0.40_04
+This document describes Mouse version 0.43
=head1 SEE ALSO