From: gfx Date: Wed, 30 Sep 2009 11:16:46 +0000 (+0900) Subject: Tidy X-Git-Tag: 0.37_01~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=8215d7254eb706c929b0cfa9efafb7a5e6db658b;p=gitmo%2FMouse.git Tidy --- diff --git a/lib/Mouse/Meta/Class.pm b/lib/Mouse/Meta/Class.pm index b5adde8..6abc7b2 100644 --- a/lib/Mouse/Meta/Class.pm +++ b/lib/Mouse/Meta/Class.pm @@ -185,17 +185,12 @@ sub _initialize_instance{ unless ($attribute->is_lazy) { my $default = $attribute->default; my $builder = $attribute->builder; - my $value = $attribute->has_builder - ? $instance->$builder - : ref($default) eq 'CODE' - ? $default->($instance) - : $default; + my $value = $builder ? $instance->$builder() + : ref($default) eq 'CODE' ? $instance->$default() + : $default; - $value = $attribute->coerce_constraint($value) - if $attribute->should_coerce; - $attribute->verify_against_type_constraint($value); - - $instance->{$key} = $value; + # XXX: we cannot use $attribute->set_value() because it invokes triggers. + $instance->{$key} = $attribute->_coerce_and_verify($value, $instance);; weaken($instance->{$key}) if ref($instance->{$key}) && $attribute->is_weak_ref; diff --git a/lib/Mouse/Meta/Method/Constructor.pm b/lib/Mouse/Meta/Method/Constructor.pm index f956fa2..f957750 100644 --- a/lib/Mouse/Meta/Method/Constructor.pm +++ b/lib/Mouse/Meta/Method/Constructor.pm @@ -12,8 +12,8 @@ sub generate_constructor_method_inline { my $buildargs = $class->_generate_BUILDARGS($metaclass); my $processattrs = $class->_generate_processattrs($metaclass, \@attrs); - my @compiled_constraints = map { $_->_compiled_type_constraint } - map { $_->{type_constraint} ? $_->{type_constraint} : () } @attrs; + my @compiled_constraints = map { $_ ? $_->_compiled_type_constraint : undef } + map { $_->type_constraint } @attrs; my $code = sprintf("#line %d %s\n", __LINE__, __FILE__).<<"..."; sub {