X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FUtil%2FTypeConstraints.pm;h=a012e9d01b237fe55401feb86a62a063fe2aa394;hp=8df17ea46e9ca4336ecb5bd4039a067902c5870c;hb=7a50b45027c9f7baad76cfce7f78c822bd38f0a7;hpb=60b5c3be4d0b3bb705df1e8d977f2ce90db6668d diff --git a/lib/Mouse/Util/TypeConstraints.pm b/lib/Mouse/Util/TypeConstraints.pm index 8df17ea..a012e9d 100644 --- a/lib/Mouse/Util/TypeConstraints.pm +++ b/lib/Mouse/Util/TypeConstraints.pm @@ -103,8 +103,20 @@ sub type { } sub subtype { - my $pkg = caller(0); - my($name, %conf) = @_; + my $pkg = caller; + + my $name; + my %conf; + + if(@_ % 2){ # odd number of arguments + $name = shift; + %conf = @_; + } + else{ + %conf = @_; + $name = $conf{name} || '__ANON__'; + } + if ($TYPE{$name} && $TYPE_SOURCE{$name} ne $pkg) { Carp::croak "The type constraint '$name' has already been created in $TYPE_SOURCE{$name} and cannot be created again in $pkg"; };