From: gfx Date: Wed, 30 Sep 2009 06:11:41 +0000 (+0900) Subject: Remove unused methods X-Git-Tag: 0.37_01~23 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=feb0e21bdab0f9e8fd0e4b2440d1a10cc9fe4667;p=gitmo%2FMouse.git Remove unused methods --- diff --git a/lib/Mouse/Meta/TypeConstraint.pm b/lib/Mouse/Meta/TypeConstraint.pm index 2588174..436f690 100644 --- a/lib/Mouse/Meta/TypeConstraint.pm +++ b/lib/Mouse/Meta/TypeConstraint.pm @@ -79,67 +79,6 @@ sub message { $_[0]->{message} } sub _compiled_type_constraint{ $_[0]->{compiled_type_constraint} } -sub check { - my $self = shift; - $self->_compiled_type_constraint->(@_); -} - -sub validate { - 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; - - confess($error); -} - -sub get_message { - my ($self, $value) = @_; - if ( my $msg = $self->message ) { - local $_ = $value; - return $msg->($value); - } - else { - $value = ( defined $value ? overload::StrVal($value) : 'undef' ); - return - "Validation failed for '" - . $self->name - . "' failed with value $value"; - } -} - -sub is_a_type_of{ - my($self, $other) = @_; - - # ->is_a_type_of('__ANON__') is always false - return 0 if !blessed($other) && $other eq '__ANON__'; - - (my $other_name = $other) =~ s/\s+//g; - - return 1 if $self->name eq $other_name; - - if(exists $self->{type_constraints}){ # union - foreach my $type(@{$self->{type_constraints}}){ - return 1 if $type->name eq $other_name; - } - } - - for(my $parent = $self->parent; defined $parent; $parent = $parent->parent){ - return 1 if $parent->name eq $other_name; - } - - return 0; -} sub compile_type_constraint{ my($self) = @_; @@ -195,6 +134,47 @@ sub compile_type_constraint{ return; } +sub check { + my $self = shift; + $self->_compiled_type_constraint->(@_); +} + +sub get_message { + my ($self, $value) = @_; + if ( my $msg = $self->message ) { + local $_ = $value; + return $msg->($value); + } + else { + $value = ( defined $value ? overload::StrVal($value) : 'undef' ); + return "Validation failed for '$self' failed with value $value"; + } +} + +sub is_a_type_of{ + my($self, $other) = @_; + + # ->is_a_type_of('__ANON__') is always false + return 0 if !blessed($other) && $other eq '__ANON__'; + + (my $other_name = $other) =~ s/\s+//g; + + return 1 if $self->name eq $other_name; + + if(exists $self->{type_constraints}){ # union + foreach my $type(@{$self->{type_constraints}}){ + return 1 if $type->name eq $other_name; + } + } + + for(my $parent = $self->parent; defined $parent; $parent = $parent->parent){ + return 1 if $parent->name eq $other_name; + } + + return 0; +} + + 1; __END__