From: Daisuke Maki Date: Tue, 3 Mar 2009 16:31:20 +0000 (+0000) Subject: check for has_default too X-Git-Tag: 0.19~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=15ce26e85c2948fc21bf594780b8562c97faf27a;p=gitmo%2FMouse.git check for has_default too --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 4387bcd..9675ac3 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -114,7 +114,13 @@ sub generate_accessor { $accessor .= 'confess "Cannot assign a value to a read-only accessor" if scalar(@_) >= 2;' . "\n"; } - if ($attribute->is_lazy) { + # XXX - edit by lestrrat 20090304: + # I couldn't quite tell why this happened, but I encountered a case + # where the default value was not set. In introspecting the resulting + # $accessor string, I realized that there was no default handling code. + # which led me to adding "|| $attribute->has_default" below. + # Tests passed, so I hope everything will be ok + if ($attribute->is_lazy || $attribute->has_default) { $accessor .= $self.'->{'.$key.'} = '; $accessor .= $attribute->has_builder