X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo%2FMouse.git;a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FTypeConstraint.pm;h=916acc130b921c947a2cd43898706a2d09e3d8f6;hp=51b08670f70e0338af416f735163696202903528;hb=6d28c5cf89bfd4c00e675e95aff6c31b61aeb805;hpb=37dc67cb9daf91c9530e5ffc762de36cb0432c7f diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 51b0867..916acc1 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -1,11 +1,14 @@ package Mouse::Meta::TypeConstraint; use strict; use warnings; -use Carp (); use overload '""' => sub { shift->{name} }, # stringify to tc name fallback => 1; +use Carp (); + +use Mouse::Util (); + sub new { my $class = shift; my %args = @_; @@ -69,6 +72,13 @@ sub get_message { } } +sub is_a_type_of{ + my($self, $tc_name) = @_; + + return $self->name eq $tc_name + || $self->name =~ /\A $tc_name \[/xms; # "ArrayRef" =~ "ArrayRef[Foo]" +} + 1; __END__