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 { {} }
$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__
=item B<new>
+=item B<get_parent_registry>
+
+=item B<set_parent_registry ($registry)>
+
+=item B<has_parent_registry>
+
=item B<type_constraints>
-=item B<has_type_constraint>
+=item B<has_type_constraint ($type_name)>
+
+=item B<get_type_constraint ($type_name)>
-=item B<get_type_constraint>
+=item B<add_type_constraint ($type)>
-=item B<add_type_constraint>
+=item B<find_type_constraint ($type_name)>
=back
# 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;