line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
6
|
|
|
6
|
|
3277
|
use 5.006; # our |
|
6
|
|
|
|
|
16
|
|
2
|
6
|
|
|
6
|
|
24
|
use strict; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
124
|
|
3
|
6
|
|
|
6
|
|
24
|
use warnings; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
423
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Search::GIN::Extract::ClassMap::Role; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# ABSTRACT: A base role for maps containing classes and associated handlers. |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
our $VERSION = '1.000003'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY |
12
|
|
|
|
|
|
|
|
13
|
6
|
|
|
6
|
|
2505
|
use Moose::Role 0.90 qw( requires has ); |
|
6
|
|
|
|
|
400792
|
|
|
6
|
|
|
|
|
28
|
|
14
|
6
|
|
|
6
|
|
20667
|
use Search::GIN::Extract::ClassMap::Types qw( CoercedClassMap ); |
|
6
|
|
|
|
|
17
|
|
|
6
|
|
|
|
|
47
|
|
15
|
6
|
|
|
6
|
|
8393
|
use namespace::autoclean; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
39
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
requires 'matches'; |
31
|
|
|
|
|
|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
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
has classmap => ( |
95
|
|
|
|
|
|
|
isa => CoercedClassMap, |
96
|
|
|
|
|
|
|
coerce => 1, |
97
|
|
|
|
|
|
|
is => 'rw', |
98
|
|
|
|
|
|
|
default => sub { +{} }, |
99
|
|
|
|
|
|
|
traits => [qw( Hash )], |
100
|
|
|
|
|
|
|
handles => { |
101
|
|
|
|
|
|
|
'classmap_entries' => 'keys', |
102
|
|
|
|
|
|
|
'classmap_set' => 'set', |
103
|
|
|
|
|
|
|
'classmap_get' => 'get', |
104
|
|
|
|
|
|
|
}, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
|
107
|
6
|
|
|
6
|
|
736
|
no Moose::Role; |
|
6
|
|
|
|
|
9
|
|
|
6
|
|
|
|
|
54
|
|
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub extract_values { |
118
|
6
|
|
|
6
|
1
|
10
|
my ( $self, $extractee ) = @_; |
119
|
6
|
|
|
|
|
34
|
return map { $_->extract_values($extractee) } $self->matches($extractee); |
|
3
|
|
|
|
|
18
|
|
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
__END__ |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=pod |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=encoding UTF-8 |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 NAME |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Search::GIN::Extract::ClassMap::Role - A base role for maps containing classes and associated handlers. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 VERSION |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
version 1.000003 |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SYNOPSIS |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
{ |
141
|
|
|
|
|
|
|
package Foo; |
142
|
|
|
|
|
|
|
use MooseX::Role; |
143
|
|
|
|
|
|
|
with 'Search::GIN::Extract::ClassMap::Role'; |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub matches { |
146
|
|
|
|
|
|
|
my ( $self, $extractee ) = @_; |
147
|
|
|
|
|
|
|
my @m; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
for ( $self->classmap_entries ) { |
150
|
|
|
|
|
|
|
if( $extractee->some_criteria( $_ ) ) { |
151
|
|
|
|
|
|
|
push @m, $self->classmap_get( $_ ); |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
return @m; |
155
|
|
|
|
|
|
|
} |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 REQUIRED METHODS |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head2 C<matches> |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
my ( @extractors ) = $item->matches( $extractee ) |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
Must take an object and return a list of |
166
|
|
|
|
|
|
|
L<< C<Search::GIN::Extract>|Search::GIN::Extract >> items to use for it. |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
for my $extractor ( @extractors ) { |
169
|
|
|
|
|
|
|
my $metadata = $extractor->extract_values( $extractee ); |
170
|
|
|
|
|
|
|
} |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=head1 METHODS |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
=head2 C<classmap_entries> |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
my ( @classnames ) = $item->classmap_entries(); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
Fetches the C<Class> names ( C<keys> ) for all registered handlers in this |
179
|
|
|
|
|
|
|
instance. ( Accessor for L<< C<classmap>|/classmap >> ) |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=head2 C<classmap_set> |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
$item->classmap_set( $classname, $handler ); |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
Sets the handler for class C<$classname> in this instance. ( Setter for |
186
|
|
|
|
|
|
|
L<< C<classmap>|/classmap >> ) |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
=head2 C<classmap_get> |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
$item->classmap_get( $classname ); |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
Gets the handler for class C<$classname> in this instance. ( Getter for |
193
|
|
|
|
|
|
|
L<< C<classmap>|/classmap >> ) |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 C<extract_values> |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
my @values = $instance->extract_values( $extractee ); |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
extracts values from all matching rules for the object |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=head2 C<classmap> |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
my $item = Thing::That::Does::ClassMap::Role->new( |
206
|
|
|
|
|
|
|
classmap => { |
207
|
|
|
|
|
|
|
classname => handler_for_objects_of_classname |
208
|
|
|
|
|
|
|
} |
209
|
|
|
|
|
|
|
); |
210
|
|
|
|
|
|
|
# or |
211
|
|
|
|
|
|
|
$item->classmap( classmap => { ... } ); |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
This is a key => value pair set mapping classes to some Extractor to use for that class |
214
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
$item->classmap_entries # class names / keys |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
$item->classmap_set( $classname, $handler ); |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
my $handler = $item->classmap_get( $classname ); |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=over 4 |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
=item C<isa>: L<< C<CoercedClassMap>|Search::GIN::Extract::ClassMap::Types/CoercedClassMap >> |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item C<coerce>: C<< B<True> >> |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
=item C<provides>: |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=over 4 |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
=item * L<< C<classmap_entries>|/classmap_entries >> |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * L<< C<classmap_set>|/classmap_set >> |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
=item * L<< C<classmap_get>|/classmap_get >> |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
=back |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
=head1 AUTHOR |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>. |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
250
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
251
|
|
|
|
|
|
|
|
252
|
|
|
|
|
|
|
=cut |