line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Moose::Meta::TypeConstraint::Registry; |
2
|
|
|
|
|
|
|
our $VERSION = '2.2206'; |
3
|
|
|
|
|
|
|
|
4
|
390
|
|
|
390
|
|
2929
|
use strict; |
|
390
|
|
|
|
|
999
|
|
|
390
|
|
|
|
|
12041
|
|
5
|
390
|
|
|
390
|
|
2261
|
use warnings; |
|
390
|
|
|
|
|
968
|
|
|
390
|
|
|
|
|
9088
|
|
6
|
390
|
|
|
390
|
|
2145
|
use metaclass; |
|
390
|
|
|
|
|
1136
|
|
|
390
|
|
|
|
|
2321
|
|
7
|
|
|
|
|
|
|
|
8
|
390
|
|
|
390
|
|
3142
|
use Scalar::Util 'blessed'; |
|
390
|
|
|
|
|
1275
|
|
|
390
|
|
|
|
|
21673
|
|
9
|
|
|
|
|
|
|
|
10
|
390
|
|
|
390
|
|
3106
|
use parent 'Class::MOP::Object'; |
|
390
|
|
|
|
|
1327
|
|
|
390
|
|
|
|
|
2645
|
|
11
|
|
|
|
|
|
|
|
12
|
390
|
|
|
390
|
|
30683
|
use Moose::Util 'throw_exception'; |
|
390
|
|
|
|
|
1253
|
|
|
390
|
|
|
|
|
2902
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__PACKAGE__->meta->add_attribute('parent_registry' => ( |
15
|
|
|
|
|
|
|
reader => 'get_parent_registry', |
16
|
|
|
|
|
|
|
writer => 'set_parent_registry', |
17
|
|
|
|
|
|
|
predicate => 'has_parent_registry', |
18
|
|
|
|
|
|
|
Class::MOP::_definition_context(), |
19
|
|
|
|
|
|
|
)); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__PACKAGE__->meta->add_attribute('type_constraints' => ( |
22
|
|
|
|
|
|
|
reader => 'type_constraints', |
23
|
|
|
|
|
|
|
default => sub { {} }, |
24
|
|
|
|
|
|
|
Class::MOP::_definition_context(), |
25
|
|
|
|
|
|
|
)); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub new { |
28
|
391
|
|
|
391
|
1
|
38710
|
my $class = shift; |
29
|
391
|
|
|
|
|
4503
|
my $self = $class->_new(@_); |
30
|
391
|
|
|
|
|
1326
|
return $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub has_type_constraint { |
34
|
18169
|
|
|
18169
|
1
|
37358
|
my ($self, $type_name) = @_; |
35
|
18169
|
100
|
100
|
|
|
653188
|
($type_name and exists $self->type_constraints->{$type_name}) ? 1 : 0 |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub get_type_constraint { |
39
|
26437
|
|
|
26437
|
1
|
54841
|
my ($self, $type_name) = @_; |
40
|
26437
|
50
|
|
|
|
55883
|
return unless defined $type_name; |
41
|
26437
|
|
|
|
|
851346
|
$self->type_constraints->{$type_name} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub add_type_constraint { |
45
|
11553
|
|
|
11553
|
1
|
30698
|
my ($self, $type) = @_; |
46
|
|
|
|
|
|
|
|
47
|
11553
|
100
|
100
|
|
|
38927
|
unless ( $type && blessed $type && $type->isa('Moose::Meta::TypeConstraint') ) { |
|
|
|
100
|
|
|
|
|
48
|
4
|
|
|
|
|
22
|
throw_exception( InvalidTypeConstraint => registry_object => $self, |
49
|
|
|
|
|
|
|
type => $type |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
11549
|
|
|
|
|
398470
|
$self->type_constraints->{$type->name} = $type; |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub find_type_constraint { |
57
|
0
|
|
|
0
|
1
|
|
my ($self, $type_name) = @_; |
58
|
0
|
0
|
|
|
|
|
return $self->get_type_constraint($type_name) |
59
|
|
|
|
|
|
|
if $self->has_type_constraint($type_name); |
60
|
0
|
0
|
|
|
|
|
return $self->get_parent_registry->find_type_constraint($type_name) |
61
|
|
|
|
|
|
|
if $self->has_parent_registry; |
62
|
0
|
|
|
|
|
|
return; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
# ABSTRACT: registry for type constraints |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
__END__ |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=pod |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=encoding UTF-8 |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
=head1 NAME |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Moose::Meta::TypeConstraint::Registry - registry for type constraints |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 VERSION |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
version 2.2206 |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 DESCRIPTION |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This class is a registry that maps type constraint names to |
86
|
|
|
|
|
|
|
L<Moose::Meta::TypeConstraint> objects. |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Currently, it is only used internally by |
89
|
|
|
|
|
|
|
L<Moose::Util::TypeConstraints>, which creates a single global |
90
|
|
|
|
|
|
|
registry. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 INHERITANCE |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
C<Moose::Meta::TypeConstraint::Registry> is a subclass of |
95
|
|
|
|
|
|
|
L<Class::MOP::Object>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 METHODS |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 Moose::Meta::TypeConstraint::Registry->new(%options) |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This creates a new registry object based on the provided C<%options>: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=over 4 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item * parent_registry |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is an optional L<Moose::Meta::TypeConstraint::Registry> |
108
|
|
|
|
|
|
|
object. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item * type_constraints |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
This is hash reference of type names to type objects. This is |
113
|
|
|
|
|
|
|
optional. Constraints can be added to the registry after it is |
114
|
|
|
|
|
|
|
created. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=back |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head2 $registry->get_parent_registry |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Returns the registry's parent registry, if it has one. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head2 $registry->has_parent_registry |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Returns true if the registry has a parent. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head2 $registry->set_parent_registry($registry) |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Sets the parent registry. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head2 $registry->get_type_constraint($type_name) |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
This returns the L<Moose::Meta::TypeConstraint> object from the |
133
|
|
|
|
|
|
|
registry for the given name, if one exists. |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 $registry->has_type_constraint($type_name) |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Returns true if the registry has a type of the given name. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head2 $registry->add_type_constraint($type) |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
Adds a new L<Moose::Meta::TypeConstraint> object to the registry. |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 $registry->find_type_constraint($type_name) |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
This method looks in the current registry for the named type. If the |
146
|
|
|
|
|
|
|
type is not found, then this method will look in the registry's |
147
|
|
|
|
|
|
|
parent, if it has one. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 BUGS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
See L<Moose/BUGS> for details on reporting bugs. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHORS |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=over 4 |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
Jesse Luehrs <doy@cpan.org> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Shawn M Moore <sartak@cpan.org> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org> |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=item * |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Hans Dieter Pearcey <hdp@cpan.org> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item * |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Chris Prather <chris@prather.org> |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=item * |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Matt S Trout <mstrout@cpan.org> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
This software is copyright (c) 2006 by Infinity Interactive, Inc. |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
204
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=cut |