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=f90075fec9ad43f9a53cf75b04592026837a9d4f;hp=f4506db7cfb58d1e8a8450ba1c7eabbaa83c281a;hb=2b82d75d868bab0f55d4bebfaf87d7e4dc2e2777;hpb=536e3c3344d408e94ee34d3d7d4d63e485ee8aec diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index f4506db..f90075f 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -67,6 +67,10 @@ sub name; sub parent; sub message; sub has_coercion; + +sub type_parameter; +sub __is_parameterized; + sub _compiled_type_constraint; sub _compiled_type_coercion; @@ -211,15 +215,24 @@ sub parameterize{ || Carp::confess("The $name constraint cannot be used, because $param doesn't subtype from a parameterizable type"); return Mouse::Meta::TypeConstraint->new( - name => $name, - parent => $self, - parameter => $param, - constraint => $generator->($param), # must be 'constraint', not 'optimized' + name => $name, + parent => $self, + type_parameter => $param, + constraint => $generator->($param), # must be 'constraint', not 'optimized' - type => 'Parameterized', + type => 'Parameterized', ); } +sub assert_valid { + my ($self, $value) = @_; + + if(!$self->_compiled_type_constraint->($value)){ + Carp::confess($self->get_message($value)); + } + return 1; +} + 1; __END__ @@ -229,7 +242,7 @@ Mouse::Meta::TypeConstraint - The Mouse Type Constraint metaclass =head1 VERSION -This document describes Mouse version 0.50 +This document describes Mouse version 0.50_01 =head1 DESCRIPTION