From: Shawn M Moore Date: Tue, 9 Dec 2008 03:37:36 +0000 (+0000) Subject: For class constraints, it's good enough to be a subclass of that class! X-Git-Tag: 0.19~126 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=4a957f055f20438e01ad0825483f8a3b3cabc294;p=gitmo%2FMouse.git For class constraints, it's good enough to be a subclass of that class! --- diff --git a/lib/Mouse/Meta/Attribute.pm b/lib/Mouse/Meta/Attribute.pm index aa59b89..c4b5e01 100644 --- a/lib/Mouse/Meta/Attribute.pm +++ b/lib/Mouse/Meta/Attribute.pm @@ -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) { diff --git a/lib/Mouse/TypeRegistry.pm b/lib/Mouse/TypeRegistry.pm index dccc736..a10e7a4 100644 --- a/lib/Mouse/TypeRegistry.pm +++ b/lib/Mouse/TypeRegistry.pm @@ -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) } ); }