[Moose-commits] r7815 - Mouse/trunk/lib/Mouse/Meta

lestrrat at code2.0beta.co.uk lestrrat at code2.0beta.co.uk
Tue Mar 3 16:31:20 GMT 2009


Author: lestrrat
Date: 2009-03-03 08:31:20 -0800 (Tue, 03 Mar 2009)
New Revision: 7815

Modified:
   Mouse/trunk/lib/Mouse/Meta/Attribute.pm
Log:
check for has_default too

Modified: Mouse/trunk/lib/Mouse/Meta/Attribute.pm
===================================================================
--- Mouse/trunk/lib/Mouse/Meta/Attribute.pm	2009-03-03 16:10:50 UTC (rev 7814)
+++ Mouse/trunk/lib/Mouse/Meta/Attribute.pm	2009-03-03 16:31:20 UTC (rev 7815)
@@ -114,7 +114,13 @@
         $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




More information about the Moose-commits mailing list