package Mouse::Meta::Method::Constructor;
-use Mouse::Util; # 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);
my $post_process = '';
if(defined $type_constraint){
$post_process .= "\$checks[$index]->($instance_slot)";
- $post_process .= " or $attr_var->verify_type_constraint_error(q{$key}, $instance_slot, $constraint_var);\n";
+ $post_process .= " or $attr_var->_throw_type_constraint_error($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) {
- no strict 'refs';
- no warnings 'once';
-
- if (*{ $class . '::BUILD' }{CODE}) {
+ if (Mouse::Util::get_code_ref($class, 'BUILD')) {
unshift @code, qq{${class}::BUILD(\$instance, \$args);};
}
}
=head1 VERSION
-This document describes Mouse version 0.40
+This document describes Mouse version 0.50
=head1 SEE ALSO