From: Daisuke Maki Date: Wed, 4 Mar 2009 01:43:49 +0000 (+0000) Subject: reverting change: the correct answer is, X-Git-Tag: 0.19~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=commitdiff_plain;h=3aadb773974c5f2d24ea1e0f1ca439f1a5e49825;hp=15ce26e85c2948fc21bf594780b8562c97faf27a reverting change: the correct answer is, - when an attribute contains a trigger which may run upon initialization, you need to make sure that the associated trigger doesn't use another attribute, OR - that attribute that gets used is declared with a "lazy" attribute, so that the accessor generates an inlined initialization code --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index 9675ac3..4387bcd 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -114,13 +114,7 @@ sub generate_accessor { $accessor .= 'confess "Cannot assign a value to a read-only accessor" if scalar(@_) >= 2;' . "\n"; } - # 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) { + if ($attribute->is_lazy) { $accessor .= $self.'->{'.$key.'} = '; $accessor .= $attribute->has_builder