what is done for isa should be done for does, so it was written!
Stevan Little [Sun, 6 Apr 2008 21:06:39 +0000 (21:06 +0000)]
Changes
lib/Moose/Meta/Attribute.pm

diff --git a/Changes b/Changes
index fbee72c..241d561 100644 (file)
--- a/Changes
+++ b/Changes
@@ -20,7 +20,7 @@ Revision history for Perl extension Moose
 
     * Moose::Meta::Attribute
       - inherited attributes may now be extended without 
-        restriction on the type ('isa') (Sartak)
+        restriction on the type ('isa', 'does') (Sartak)
         - added tests for this (Sartak)
       - when an attribute property is malformed (such as lazy without 
         a default), give the name of the attribute in the error 
index 313c9f3..ad1822a 100644 (file)
@@ -88,6 +88,24 @@ sub clone_and_inherit_options {
         $actual_options{type_constraint} = $type_constraint;
         delete $options{isa};
     }
+    
+    if ($options{does}) {
+        my $type_constraint;
+        if (blessed($options{does}) && $options{does}->isa('Moose::Meta::TypeConstraint')) {
+            $type_constraint = $options{does};
+        }
+        else {
+            $type_constraint = Moose::Util::TypeConstraints::find_or_create_type_constraint(
+                $options{does}
+            );
+            (defined $type_constraint)
+                || confess "Could not find the type constraint '" . $options{does} . "'";
+        }
+
+        $actual_options{type_constraint} = $type_constraint;
+        delete $options{does};
+    }    
+    
     (scalar keys %options == 0)
         || confess "Illegal inherited options => (" . (join ', ' => keys %options) . ")";
     $self->clone(%actual_options);