X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FObject.pm;h=f813fd523035fceb3b845b6d0502f05bd35009f5;hb=fe5fe0612f027da06fda45ecf27d031e345895c8;hp=81cb9bf87a20aac1754b2899a813fa283141358c;hpb=2b09160967a78fa6891b553eb6ae90340c6565cb;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 81cb9bf..f813fd5 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -24,13 +24,28 @@ sub new { $attribute->trigger->{before}->($instance, $args->{$from}, $attribute); } - $attribute->verify_type_constraint($args->{$from}) - if $attribute->has_type_constraint; + if ($attribute->has_trigger && $attribute->trigger->{around}) { + $attribute->trigger->{around}->(sub { + $args->{$from} = $_[1]; - $instance->{$key} = $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; + weaken($instance->{$key}) + if ref($instance->{$key}) && $attribute->is_weak_ref; + }, $instance, $args->{$from}, $attribute); + } + else { + $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->{after}) { $attribute->trigger->{after}->($instance, $args->{$from}, $attribute);