From: Shawn M Moore Date: Wed, 4 Jun 2008 04:17:59 +0000 (+0000) Subject: builder now called in the constructor X-Git-Tag: 0.04~91 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1be61030b949daee746b57e7135202c27eeb1c2f;p=gitmo%2FMouse.git builder now called in the constructor --- diff --git a/lib/Mouse/Object.pm b/lib/Mouse/Object.pm index 2a5a639..1dd5481 100644 --- a/lib/Mouse/Object.pm +++ b/lib/Mouse/Object.pm @@ -17,11 +17,14 @@ sub new { my $default; if (!exists($args{$key})) { - if (exists($attribute->{default})) { + if (exists($attribute->{default}) || exists($attribute->{builder})) { unless ($attribute->{lazy}) { - my $default = ref($attribute->{default}) eq 'CODE' - ? $attribute->{default}->() - : $attribute->{default}; + my $builder = $attribute->{builder}; + my $default = exists($attribute->{builder}) + ? $instance->$builder + : ref($attribute->{default}) eq 'CODE' + ? $attribute->{default}->() + : $attribute->{default}; $attribute->verify_type_constraint($default) if $attribute->has_type_constraint;