2 package Moose::Meta::TypeConstraint::Registry;
8 use Scalar::Util 'blessed';
11 our $VERSION = '0.01';
12 our $AUTHORITY = 'cpan:STEVAN';
14 use base 'Class::MOP::Object';
16 __PACKAGE__->meta->add_attribute('parent_registry' => (
17 reader => 'get_parent_registry',
18 writer => 'set_parent_registry',
19 predicate => 'has_parent_registry',
22 __PACKAGE__->meta->add_attribute('type_constraints' => (
23 reader => 'type_constraints',
29 my $self = $class->meta->new_object(@_);
33 sub has_type_constraint {
34 my ($self, $type_name) = @_;
35 exists $self->type_constraints->{$type_name} ? 1 : 0
38 sub get_type_constraint {
39 my ($self, $type_name) = @_;
40 $self->type_constraints->{$type_name}
43 sub add_type_constraint {
44 my ($self, $type) = @_;
45 $self->type_constraints->{$type->name} = $type;
48 sub find_type_constraint {
49 my ($self, $type_name) = @_;
50 return $self->get_type_constraint($type_name)
51 if $self->has_type_constraint($type_name);
52 return $self->get_parent_registry->find_type_constraint($type_name)
53 if $self->has_parent_registry;
66 Moose::Meta::TypeConstraint::Registry
78 =item B<get_parent_registry>
80 =item B<set_parent_registry ($registry)>
82 =item B<has_parent_registry>
84 =item B<type_constraints>
86 =item B<has_type_constraint ($type_name)>
88 =item B<get_type_constraint ($type_name)>
90 =item B<add_type_constraint ($type)>
92 =item B<find_type_constraint ($type_name)>
98 All complex software has bugs lurking in it, and this module is no
99 exception. If you find a bug please either email me, or add the bug
104 Stevan Little E<lt>stevan@iinteractive.comE<gt>
106 =head1 COPYRIGHT AND LICENSE
108 Copyright 2006, 2007 by Infinity Interactive, Inc.
110 L<http://www.iinteractive.com>
112 This library is free software; you can redistribute it and/or modify
113 it under the same terms as Perl itself.