For class constraints, it's good enough to be a subclass of that class!
Shawn M Moore [Tue, 9 Dec 2008 03:37:36 +0000 (03:37 +0000)]
lib/Mouse/Meta/Attribute.pm
lib/Mouse/TypeRegistry.pm

index aa59b89..c4b5e01 100644 (file)
@@ -213,13 +213,13 @@ sub create {
         my $optimized_constraints = Mouse::TypeRegistry->optimized_constraints;
         if (@type_constraints == 1) {
             $code = $optimized_constraints->{$type_constraints[0]} ||
-                sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type_constraints[0] };
+                sub { Scalar::Util::blessed($_) && $_->isa($type_constraints[0]) };
             $args{type_constraint} = $type_constraints[0];
         } else {
             my @code_list = map {
                 my $type = $_;
                 $optimized_constraints->{$type} ||
-                    sub { Scalar::Util::blessed($_) && Scalar::Util::blessed($_) eq $type }
+                    sub { Scalar::Util::blessed($_) && $_->isa($type) }
             } @type_constraints;
             $code = sub {
                 for my $code (@code_list) {
index dccc736..a10e7a4 100644 (file)
@@ -128,9 +128,7 @@ sub _class_type {
     my $class = $conf->{class};
     Mouse::load_class($class);
     _subtype(
-        $name => where => sub {
-            defined $_ && ref($_) eq $class;
-        }
+        $name => where => sub { $_->isa($class) }
     );
 }