X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FObject.pm;h=5b7d17ea07906a79d3a90f279c12d67d12688051;hb=8fd9e611aa5ab3bc951c0ff4e300ecbe1f9b0c0f;hp=2138adf8df5119e3a71b0207eb8bcc6453ce71e4;hpb=28d269491e4b8dad61231390965529c3993a2ba5;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 2138adf..5b7d17e 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -28,7 +28,20 @@ sub new { my $key = $attribute->name; my $default; - if (!exists($args{$from})) { + if (defined($from) && exists($args{$from})) { + $attribute->verify_type_constraint($args{$from}) + if $attribute->has_type_constraint; + + $instance->{$key} = $args{$from}; + + weaken($instance->{$key}) + if ref($instance->{$key}) && $attribute->is_weak_ref; + + if ($attribute->has_trigger) { + $attribute->trigger->($instance, $args{$from}, $attribute); + } + } + else { if ($attribute->has_default || $attribute->has_builder) { unless ($attribute->is_lazy) { my $default = $attribute->default; @@ -54,20 +67,6 @@ sub new { } } } - - if (exists($args{$from})) { - $attribute->verify_type_constraint($args{$from}) - if $attribute->has_type_constraint; - - $instance->{$key} = $args{$from}; - - weaken($instance->{$key}) - if ref($instance->{$key}) && $attribute->is_weak_ref; - - if ($attribute->has_trigger) { - $attribute->trigger->($instance, $args{$from}, $attribute); - } - } } $instance->BUILDALL(\%args);