use warnings;
use MRO::Compat;
-use Scalar::Util 'blessed';
+use Scalar::Util qw/blessed weaken/;
use Carp 'confess';
sub new {
if (!exists($args{$key})) {
if ($attribute->has_default || $attribute->has_builder) {
- my $default = $attribute->default;
-
- unless ($attribute->lazy) {
+ unless ($attribute->is_lazy) {
+ my $default = $attribute->default;
my $builder = $attribute->builder;
my $value = $attribute->has_builder
? $instance->$builder
$instance->{$key} = $value;
- Scalar::Util::weaken($instance->{$key})
+ weaken($instance->{$key})
if $attribute->weak_ref;
}
}
else {
- if ($attribute->required) {
- confess "Attribute '".$attribute->name."' is required";
+ if ($attribute->is_required) {
+ confess "Attribute (".$attribute->name.") is required";
}
}
}
$instance->{$key} = $args{$key};
- Scalar::Util::weaken($instance->{$key})
+ weaken($instance->{$key})
if $attribute->weak_ref;
if ($attribute->has_trigger) {