builder now called in the constructor
Shawn M Moore [Wed, 4 Jun 2008 04:17:59 +0000 (04:17 +0000)]
lib/Mouse/Object.pm

index 2a5a639..1dd5481 100644 (file)
@@ -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;