Created
March 8, 2009 13:02
-
-
Save lestrrat/75781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=== lib/Mouse/Util/TypeConstraints.pm | |
================================================================== | |
--- lib/Mouse/Util/TypeConstraints.pm (revision 101886) | |
+++ lib/Mouse/Util/TypeConstraints.pm (local) | |
@@ -106,6 +106,7 @@ | |
} else { | |
$TYPE{$name} = $constraint; | |
} | |
+ return $name; | |
} | |
sub coerce { | |
@@ -137,12 +138,16 @@ | |
} | |
sub class_type { | |
- my $pkg = caller(0); | |
my($name, $conf) = @_; | |
- my $class = $conf->{class}; | |
- subtype( | |
- $name => where => sub { $_->isa($class) } | |
- ); | |
+ if ($conf && $conf->{class}) { | |
+ # No, you're using this wrong | |
+ warn "class_type() should be class_type(ClassName). Perhaps you're looking for subtype $name => as '$conf->{class}'?"; | |
+ subtype($name, as => $conf->{class}); | |
+ } else { | |
+ subtype( | |
+ $name => where => sub { $_->isa($name) } | |
+ ); | |
+ } | |
} | |
sub role_type { | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment