From: Stevan Little <stevan.little@iinteractive.com>
Date: Tue, 21 Mar 2006 20:17:41 +0000 (+0000)
Subject: whoops
X-Git-Tag: 0_24~3
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a977cf65eb3de88266b8f4b98936b43b8fbc03dd;p=gitmo%2FClass-MOP.git

whoops
---

diff --git a/Changes b/Changes
index ef87414..b460151 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,10 @@
 Revision history for Perl extension Class-MOP.
 
+0.23
+	* Class::MOP::Class
+	  - fixed the way attribute defaults are handled 
+	    during instance construction (bug found by chansen)
+
 0.22 Mon. March 20, 2006
     * Class::MOP::Class
       - localized $@ in the *_package_variable functions
diff --git a/README b/README
index 700052e..7767d47 100644
--- a/README
+++ b/README
@@ -1,4 +1,4 @@
-Class::MOP version 0.22
+Class::MOP version 0.23
 ===========================
 
 See the individual module documentation for more information
diff --git a/examples/ClassEncapsulatedAttributes.pod b/examples/ClassEncapsulatedAttributes.pod
index ff486ad..3c6776a 100644
--- a/examples/ClassEncapsulatedAttributes.pod
+++ b/examples/ClassEncapsulatedAttributes.pod
@@ -5,7 +5,7 @@ package # hide the package from PAUSE
 use strict;
 use warnings;
 
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 use base 'Class::MOP::Class';
 
@@ -35,7 +35,9 @@ sub construct_instance {
                    exists ${$params{$current_class}}{$init_arg};
             # if nothing was in the %params, we can use the 
             # attribute's default value (if it has one)
-            $val ||= $attr->default($instance) if $attr->has_default();
+            if (!defined $val && $attr->has_default) {
+                $val = $attr->default($instance); 
+            }
             # now add this to the instance structure
             $instance->{$current_class}->{$attr_name} = $val;
         }
diff --git a/examples/InsideOutClass.pod b/examples/InsideOutClass.pod
index 653f917..1139f92 100644
--- a/examples/InsideOutClass.pod
+++ b/examples/InsideOutClass.pod
@@ -5,7 +5,7 @@ package # hide the package from PAUSE
 use strict;
 use warnings;
 
-our $VERSION = '0.03';
+our $VERSION = '0.04';
 
 use Scalar::Util 'refaddr';
 
@@ -25,7 +25,9 @@ sub construct_instance {
         $val = $params{$init_arg} if exists $params{$init_arg};
         # if nothing was in the %params, we can use the 
         # attribute's default value (if it has one)
-        $val ||= $attr->default($instance) if $attr->has_default();
+        if (!defined $val && $attr->has_default) {
+            $val = $attr->default($instance); 
+        }
         # now add this to the instance structure
         $class->get_package_variable('%' . $attr->name)->{ refaddr($instance) } = $val;
     }    
diff --git a/lib/Class/MOP.pm b/lib/Class/MOP.pm
index a9c36d9..d6f3a58 100644
--- a/lib/Class/MOP.pm
+++ b/lib/Class/MOP.pm
@@ -11,7 +11,7 @@ use Class::MOP::Class;
 use Class::MOP::Attribute;
 use Class::MOP::Method;
 
-our $VERSION = '0.22';
+our $VERSION = '0.23';
 
 ## ----------------------------------------------------------------------------
 ## Setting up our environment ...
diff --git a/lib/Class/MOP/Class.pm b/lib/Class/MOP/Class.pm
index d4a8cab..2ff2c82 100644
--- a/lib/Class/MOP/Class.pm
+++ b/lib/Class/MOP/Class.pm
@@ -9,7 +9,7 @@ use Scalar::Util 'blessed', 'reftype';
 use Sub::Name    'subname';
 use B            'svref_2object';
 
-our $VERSION = '0.08';
+our $VERSION = '0.09';
 
 # Self-introspection 
 
@@ -163,7 +163,9 @@ sub construct_instance {
         $val = $params{$init_arg} if exists $params{$init_arg};
         # if nothing was in the %params, we can use the 
         # attribute's default value (if it has one)
-        $val ||= $attr->default($instance) if $attr->has_default();            
+        if (!defined $val && $attr->has_default) {
+            $val = $attr->default($instance); 
+        }            
         $instance->{$attr->name} = $val;
     }
     return $instance;