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=13b44954c5042e659610816dcaf21f02d0db29fd;hp=7b8732d9d8eadc7679b294bf8ee110984d6f943e;hb=a133bcea30632f3bdb815d5001e364675dc14028;hpb=90fe520e5db8715b510a2ca3bef0847c4503e037 diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 7b8732d..13b4495 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 qw(:meta); + sub new { my $class = shift; my %args = @_; @@ -31,23 +34,23 @@ sub check { } sub validate { - my ($self, $value) = @_; - if ($self->{_compiled_type_constraint}->($value)) { - return undef; - } - else { - $self->get_message($value); - } + my ($self, $value) = @_; + if ($self->{_compiled_type_constraint}->($value)) { + return undef; + } + else { + $self->get_message($value); + } } -sub assert_valid { - my ($self, $value) = @_; - - my $error = $self->validate($value); - return 1 if ! defined $error; +sub assert_valid { + my ($self, $value) = @_; + + my $error = $self->validate($value); + return 1 if ! defined $error; - Carp::confess($error); -} + Carp::confess($error); +} sub message { @@ -81,7 +84,7 @@ __END__ =head1 NAME -Mouse::Meta::TypeConstraint - The Mouse Type Constraint Metaclass +Mouse::Meta::TypeConstraint - The Mouse Type Constraint metaclass =head1 DESCRIPTION @@ -103,5 +106,9 @@ Don't use this. =back +=head1 SEE ALSO + +L + =cut