From: Stevan Little Date: Fri, 14 Sep 2007 05:39:42 +0000 (+0000) Subject: adding ->parent_registry to the TC registry object X-Git-Tag: 0_26~19 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=183ba44e79132094cc1cb595fcf206f24365a778;p=gitmo%2FMoose.git adding ->parent_registry to the TC registry object --- diff --git a/lib/Moose/Meta/TypeConstraint/Registry.pm b/lib/Moose/Meta/TypeConstraint/Registry.pm index c1414d0..ae6429a 100644 --- a/lib/Moose/Meta/TypeConstraint/Registry.pm +++ b/lib/Moose/Meta/TypeConstraint/Registry.pm @@ -13,6 +13,12 @@ our $AUTHORITY = 'cpan:STEVAN'; use base 'Class::MOP::Object'; +__PACKAGE__->meta->add_attribute('parent_registry' => ( + reader => 'get_parent_registry', + writer => 'set_parent_registry', + predicate => 'has_parent_registry', +)); + __PACKAGE__->meta->add_attribute('type_constraints' => ( reader => 'type_constraints', default => sub { {} } @@ -39,6 +45,15 @@ sub add_type_constraint { $self->type_constraints->{$type->name} = $type; } +sub find_type_constraint { + my ($self, $type_name) = @_; + return $self->get_type_constraint($type_name) + if $self->has_type_constraint($type_name); + return $self->get_parent_registry->find_type_constraint($type_name) + if $self->has_parent_registry; + return; +} + 1; __END__ @@ -60,13 +75,21 @@ Moose::Meta::TypeConstraint::Registry =item B +=item B + +=item B + +=item B + =item B -=item B +=item B + +=item B -=item B +=item B -=item B +=item B =back diff --git a/lib/Moose/Util/TypeConstraints.pm b/lib/Moose/Util/TypeConstraints.pm index 5d01e2c..cc36e8e 100644 --- a/lib/Moose/Util/TypeConstraints.pm +++ b/lib/Moose/Util/TypeConstraints.pm @@ -17,20 +17,20 @@ our $AUTHORITY = 'cpan:STEVAN'; # predeclaration ensures the prototypes are in scope when consumers are # compiled -sub find_type_constraint ($); -sub _create_type_constraint ($$$;$$); -sub _install_type_coercions ($$); +sub find_type_constraint ($); +sub _create_type_constraint ($$$;$$); +sub _install_type_coercions ($$); sub create_type_constraint_union (@); -sub type ($$;$$); -sub subtype ($$;$$$); -sub coerce ($@); -sub as ($); -sub from ($); -sub where (&); -sub via (&); -sub message (&); -sub optimize_as (&); -sub enum ($;@); +sub type ($$;$$); +sub subtype ($$;$$$); +sub coerce ($@); +sub as ($); +sub from ($); +sub where (&); +sub via (&); +sub message (&); +sub optimize_as (&); +sub enum ($;@); use Moose::Meta::TypeConstraint; use Moose::Meta::TypeCoercion;