line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# |
2
|
|
|
|
|
|
|
# This file is part of MooseX-Attribute-Deflator |
3
|
|
|
|
|
|
|
# |
4
|
|
|
|
|
|
|
# This software is Copyright (c) 2012 by Moritz Onken. |
5
|
|
|
|
|
|
|
# |
6
|
|
|
|
|
|
|
# This is free software, licensed under: |
7
|
|
|
|
|
|
|
# |
8
|
|
|
|
|
|
|
# The (three-clause) BSD License |
9
|
|
|
|
|
|
|
# |
10
|
|
|
|
|
|
|
package MooseX::Attribute::Deflator::Registry; |
11
|
|
|
|
|
|
|
{ |
12
|
|
|
|
|
|
|
$MooseX::Attribute::Deflator::Registry::VERSION = '2.1.11'; # TRIAL |
13
|
|
|
|
|
|
|
} |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# ABSTRACT: Registry class for attribute deflators |
16
|
8
|
|
|
8
|
|
26
|
use Moose; |
|
8
|
|
|
|
|
8
|
|
|
8
|
|
|
|
|
49
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
has deflators => ( |
19
|
|
|
|
|
|
|
traits => ['Hash'], |
20
|
|
|
|
|
|
|
is => 'rw', |
21
|
|
|
|
|
|
|
isa => 'HashRef[CodeRef]', |
22
|
|
|
|
|
|
|
default => sub { {} }, |
23
|
|
|
|
|
|
|
handles => { |
24
|
|
|
|
|
|
|
has_deflator => 'get', |
25
|
|
|
|
|
|
|
get_deflator => 'get', |
26
|
|
|
|
|
|
|
set_deflator => 'set', |
27
|
|
|
|
|
|
|
_add_deflator => 'set', |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
has inlined_deflators => ( |
32
|
|
|
|
|
|
|
traits => ['Hash'], |
33
|
|
|
|
|
|
|
is => 'rw', |
34
|
|
|
|
|
|
|
isa => 'HashRef[CodeRef]', |
35
|
|
|
|
|
|
|
default => sub { {} }, |
36
|
|
|
|
|
|
|
handles => { |
37
|
|
|
|
|
|
|
has_inlined_deflator => 'get', |
38
|
|
|
|
|
|
|
get_inlined_deflator => 'get', |
39
|
|
|
|
|
|
|
set_inlined_deflator => 'set', |
40
|
|
|
|
|
|
|
_add_inlined_deflator => 'set', |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
); |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has inflators => ( |
45
|
|
|
|
|
|
|
traits => ['Hash'], |
46
|
|
|
|
|
|
|
is => 'rw', |
47
|
|
|
|
|
|
|
isa => 'HashRef[CodeRef]', |
48
|
|
|
|
|
|
|
default => sub { {} }, |
49
|
|
|
|
|
|
|
handles => { |
50
|
|
|
|
|
|
|
has_inflator => 'get', |
51
|
|
|
|
|
|
|
get_inflator => 'get', |
52
|
|
|
|
|
|
|
set_inflator => 'set', |
53
|
|
|
|
|
|
|
_add_inflator => 'set', |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
has inlined_inflators => ( |
58
|
|
|
|
|
|
|
traits => ['Hash'], |
59
|
|
|
|
|
|
|
is => 'rw', |
60
|
|
|
|
|
|
|
isa => 'HashRef[CodeRef]', |
61
|
|
|
|
|
|
|
default => sub { {} }, |
62
|
|
|
|
|
|
|
handles => { |
63
|
|
|
|
|
|
|
has_inlined_inflator => 'get', |
64
|
|
|
|
|
|
|
get_inlined_inflator => 'get', |
65
|
|
|
|
|
|
|
set_inlined_inflator => 'set', |
66
|
|
|
|
|
|
|
_add_inlined_inflator => 'set', |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub add_deflator { |
71
|
63
|
|
|
63
|
1
|
76
|
my ( $self, $name, $deflator, $inlined ) = @_; |
72
|
63
|
100
|
|
|
|
2330
|
$self->_add_inlined_deflator( $name, $inlined ) if ($inlined); |
73
|
63
|
|
|
|
|
2266
|
return $self->_add_deflator( $name, $deflator ); |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub find_deflator { |
77
|
168
|
|
|
168
|
1
|
21324
|
my ( $self, $constraint, $norecurse ) = @_; |
78
|
168
|
|
|
|
|
2840
|
( my $name = $constraint->name ) =~ s/\[.*\]/\[\]/; |
79
|
168
|
|
|
|
|
23280
|
my $sub = $self->get_deflator($name); |
80
|
168
|
100
|
|
|
|
3496
|
return ( $constraint, $sub, $self->get_inlined_deflator($name) ) |
81
|
|
|
|
|
|
|
if ($sub); |
82
|
78
|
50
|
|
|
|
119
|
return undef if ($norecurse); |
83
|
78
|
50
|
|
|
|
1492
|
return $self->find_deflator( $constraint->parent ) |
84
|
|
|
|
|
|
|
if ( $constraint->has_parent ); |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub add_inflator { |
88
|
61
|
|
|
61
|
1
|
71
|
my ( $self, $name, $inflator, $inlined ) = @_; |
89
|
61
|
100
|
|
|
|
2338
|
$self->_add_inlined_inflator( $name, $inlined ) if ($inlined); |
90
|
61
|
|
|
|
|
2189
|
return $self->_add_inflator( $name, $inflator ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub find_inflator { |
94
|
164
|
|
|
164
|
1
|
18483
|
my ( $self, $constraint, $norecurse ) = @_; |
95
|
164
|
|
|
|
|
2896
|
( my $name = $constraint->name ) =~ s/\[.*\]/\[\]/; |
96
|
164
|
|
|
|
|
21321
|
my $sub = $self->get_inflator($name); |
97
|
164
|
100
|
|
|
|
3456
|
return ( $constraint, $sub, $self->get_inlined_inflator($name) ) |
98
|
|
|
|
|
|
|
if ($sub); |
99
|
77
|
50
|
|
|
|
119
|
return undef if ($norecurse); |
100
|
77
|
50
|
|
|
|
1515
|
return $self->find_inflator( $constraint->parent ) |
101
|
|
|
|
|
|
|
if ( $constraint->has_parent ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
1; |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=pod |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 NAME |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
MooseX::Attribute::Deflator::Registry - Registry class for attribute deflators |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=head1 VERSION |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
version 2.1.11 |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=head1 DESCRIPTION |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
This class contains a registry for deflator and inflator functions. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item B<< inflators ( isa => HashRef[CodeRef] ) >> |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item B<< deflators ( isa => HashRef[CodeRef] ) >> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 METHODS |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=over 4 |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item B<< add_inflator( $type_constraint, $coderef ) >> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item B<< add_deflator( $type_constraint, $coderef ) >> |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item B<< set_inflator( $type_constraint, $coderef ) >> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item B<< set_deflator( $type_constraint, $coderef ) >> |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Add a inflator/deflator function for C<$type_constraint>. Existing functions |
145
|
|
|
|
|
|
|
are overwritten. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item B<< has_inflator( $type_constraint ) >> |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item B<< has_deflator( $type_constraint ) >> |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
Predicate methods. |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item B<< find_inflator( $type_constraint ) >> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item B<< find_deflator( $type_constraint ) >> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Finds a suitable deflator/inflator by bubbling up the type hierarchy. |
158
|
|
|
|
|
|
|
it returns the matching type constraint, its deflator an optionally |
159
|
|
|
|
|
|
|
its inlined deflator if it exists. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=back |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 AUTHOR |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Moritz Onken |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
This software is Copyright (c) 2012 by Moritz Onken. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
This is free software, licensed under: |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
The (three-clause) BSD License |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=cut |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |
179
|
|
|
|
|
|
|
|