X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FTypeConstraint.pm;h=029e0165f4392835eb2c6250230a87a2a2d312a9;hb=refs%2Ftags%2F0.50_03;hp=023cb37d948f1c9cffe72fd6616dda0a125df0df;hpb=05a12aa45fbcd22111d4f5dde2736c8361540198;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 023cb37..029e016 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; @@ -211,15 +213,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 +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_03 =head1 DESCRIPTION