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=2593b8250a3bb7bf64636b1fc0679d1f3163d9f1;hp=56d5cedfa0ab41d693d153ff1f18ea1d983a527b;hb=de0d4152ac07ed26a928841729e97366187b2915;hpb=02bf7ed13ae5d43392767a38fe71e9606f1dba76 diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 56d5ced..2593b82 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -81,6 +81,15 @@ sub create_child_type{ ); } +sub name; +sub parent; +sub message; +sub has_coercion; +sub _compiled_type_constraint; +sub _compiled_type_coercion; + +sub compile_type_constraint; + sub _add_type_coercions{ my $self = shift; @@ -129,10 +138,14 @@ sub check { sub coerce { my $self = shift; + my $coercion = $self->_compiled_type_coercion; + if(!$coercion){ + Carp::confess("Cannot coerce without a type coercion"); + } + return $_[0] if $self->_compiled_type_constraint->(@_); - my $coercion = $self->_compiled_type_coercion; - return $coercion ? $coercion->(@_) : $_[0]; + return $coercion->(@_); } sub get_message { @@ -203,7 +216,7 @@ Mouse::Meta::TypeConstraint - The Mouse Type Constraint metaclass =head1 VERSION -This document describes Mouse version 0.48 +This document describes Mouse version 0.49 =head1 DESCRIPTION