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=5650c253c7a79e3e572f0229eb2253c16f219d44;hp=f6bdac8bcfc1ba4da5a8fc9f30ee2259893b9dc4;hb=7fc19c3fe6c387eea8d5275aa830b3a43016fabc;hpb=fc83f4cf2ef7708120a216bddc285b93082d7958 diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index f6bdac8..5650c25 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -35,8 +35,6 @@ sub new { Carp::confess("Constraint for $args{name} is not a CODE reference"); } - $args{package_defined_in} ||= caller; - my $self = bless \%args, $class; $self->compile_type_constraint() if !$self->{hand_optimized_type_constraint}; @@ -67,6 +65,10 @@ sub name; sub parent; sub message; sub has_coercion; + +sub type_parameter; +sub __is_parameterized; + sub _compiled_type_constraint; sub _compiled_type_coercion; @@ -220,6 +222,15 @@ sub parameterize{ ); } +sub assert_valid { + my ($self, $value) = @_; + + if(!$self->_compiled_type_constraint->($value)){ + Carp::confess($self->get_message($value)); + } + return 1; +} + 1; __END__ @@ -229,7 +240,7 @@ Mouse::Meta::TypeConstraint - The Mouse Type Constraint metaclass =head1 VERSION -This document describes Mouse version 0.50_01 +This document describes Mouse version 0.50_02 =head1 DESCRIPTION