[Moose-commits] r7882 -
MooseX-Types-Dependent/trunk/lib/MooseX/Meta/TypeConstraint
jnapiorkowski at code2.0beta.co.uk
jnapiorkowski at code2.0beta.co.uk
Wed Apr 1 22:18:49 BST 2009
Author: jnapiorkowski
Date: 2009-04-01 14:18:48 -0700 (Wed, 01 Apr 2009)
New Revision: 7882
Modified:
MooseX-Types-Dependent/trunk/lib/MooseX/Meta/TypeConstraint/Dependent.pm
Log:
first go at equals api
Modified: MooseX-Types-Dependent/trunk/lib/MooseX/Meta/TypeConstraint/Dependent.pm
===================================================================
--- MooseX-Types-Dependent/trunk/lib/MooseX/Meta/TypeConstraint/Dependent.pm 2009-04-01 16:18:40 UTC (rev 7881)
+++ MooseX-Types-Dependent/trunk/lib/MooseX/Meta/TypeConstraint/Dependent.pm 2009-04-01 21:18:48 UTC (rev 7882)
@@ -271,59 +271,27 @@
);
};
-=head2 is_a_type_of
-
-=head2 is_subtype_of
-
=head2 equals
Override the base class behavior.
- TBD
+=cut
sub equals {
my ( $self, $type_or_name ) = @_;
- my $other = Moose::Util::TypeConstraints::find_type_constraint($type_or_name);
+ my $other = Moose::Util::TypeConstraints::find_type_constraint("$type_or_name");
- return unless $other->isa(__PACKAGE__);
-
return (
- $self->type_constraints_equals($other)
+ $other->isa(__PACKAGE__)
and
- $self->parent->equals( $other->parent )
+ $self->dependent_type_constraint->equals($other)
+ and
+ $self->constraining_type_constraint->equals($other)
+ and
+ $self->parent->equals($other->parent)
);
}
-=head2 type_constraints_equals
-
-Checks to see if the internal type contraints are equal.
-
- TBD
-
-sub type_constraints_equals {
- my ($self, $other) = @_;
- my @self_type_constraints = @{$self->type_constraints||[]};
- my @other_type_constraints = @{$other->type_constraints||[]};
-
- ## Incoming ay be either arrayref or hashref, need top compare both
- while(@self_type_constraints) {
- my $self_type_constraint = shift @self_type_constraints;
- my $other_type_constraint = shift @other_type_constraints
- || return; ## $other needs the same number of children.
-
- if( ref $self_type_constraint) {
- $self_type_constraint->equals($other_type_constraint)
- || return; ## type constraints obviously need top be equal
- } else {
- $self_type_constraint eq $other_type_constraint
- || return; ## strings should be equal
- }
-
- }
-
- return 1; ##If we get this far, everything is good.
-}
-
=head2 get_message
Give you a better peek into what's causing the error.
More information about the Moose-commits
mailing list