Skip to content

Instantly share code, notes, and snippets.

@lestrrat
Created March 8, 2009 13:02
Show Gist options
  • Save lestrrat/75781 to your computer and use it in GitHub Desktop.
Save lestrrat/75781 to your computer and use it in GitHub Desktop.
=== 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