line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
27577
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
51
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package Search::GIN::Extract::ClassMap; |
5
|
|
|
|
|
|
|
BEGIN { |
6
|
1
|
|
|
1
|
|
50
|
$Search::GIN::Extract::ClassMap::AUTHORITY = 'cpan:KENTNL'; |
7
|
|
|
|
|
|
|
} |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
$Search::GIN::Extract::ClassMap::VERSION = '0.01060817'; |
10
|
|
|
|
|
|
|
} |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# ABSTRACT: Delegate Extraction based on class. |
13
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
397
|
use Moose 0.90; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use Search::GIN::Extract::ClassMap::Types qw( :all ); |
16
|
|
|
|
|
|
|
use aliased 'Search::GIN::Extract::ClassMap::Isa' => 'CMIsa'; |
17
|
|
|
|
|
|
|
use aliased 'Search::GIN::Extract::ClassMap::Does' => 'CMDoes'; |
18
|
|
|
|
|
|
|
use aliased 'Search::GIN::Extract::ClassMap::Like' => 'CMLike'; |
19
|
|
|
|
|
|
|
use namespace::autoclean; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
with qw( |
24
|
|
|
|
|
|
|
Search::GIN::Extract |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'extract_isa' => ( 'isa', IsaClassMap, 'is', 'rw', 'coerce', 1, default => sub { CMIsa->new() } ); |
29
|
|
|
|
|
|
|
has 'extract_does' => ( 'isa', DoesClassMap, 'is', 'rw', 'coerce', 1, default => sub { CMDoes->new() } ); |
30
|
|
|
|
|
|
|
has 'extract' => ( 'isa', LikeClassMap, 'is', 'rw', 'coerce', 1, default => sub { CMLike->new() } ); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub extract_values { |
34
|
|
|
|
|
|
|
my ( $self, $object ) = @_; |
35
|
|
|
|
|
|
|
my @found; |
36
|
|
|
|
|
|
|
for ( $self->extract_isa, $self->extract_does, $self->extract ) { |
37
|
|
|
|
|
|
|
push @found, $_->extract_values($object); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
return @found; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
no Moose; |
43
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
44
|
|
|
|
|
|
|
1; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__END__ |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=pod |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 NAME |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Search::GIN::Extract::ClassMap - Delegate Extraction based on class. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 VERSION |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
version 0.01060817 |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 SYNOPSIS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $extractor = Search::GIN::Extract::ClassMap->new( |
61
|
|
|
|
|
|
|
extract_isa => { |
62
|
|
|
|
|
|
|
'Foo' => [qw( bar baz quux )], |
63
|
|
|
|
|
|
|
'Bar' => Search::GIN::Extract::AttributeIndex->new(), |
64
|
|
|
|
|
|
|
'Baz' => sub { shift; my $object = shift; { a => $object->a() } }, |
65
|
|
|
|
|
|
|
}, |
66
|
|
|
|
|
|
|
extract_does => { |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
}, |
69
|
|
|
|
|
|
|
extract => { |
70
|
|
|
|
|
|
|
/* either ISA or DOES */ |
71
|
|
|
|
|
|
|
}, |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
In reality, the form is more like this: |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $extractor = Search::GIN::Extract::ClassMap->new( |
77
|
|
|
|
|
|
|
extract_isa => { |
78
|
|
|
|
|
|
|
'Foo' => Search::GIN::Extract::*, |
79
|
|
|
|
|
|
|
'Bar' => Search::GIN::Extract::*, |
80
|
|
|
|
|
|
|
'Baz' => Search::GIN::Extract::*, |
81
|
|
|
|
|
|
|
}, |
82
|
|
|
|
|
|
|
extract_does => { |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
}, |
85
|
|
|
|
|
|
|
extract => { |
86
|
|
|
|
|
|
|
/* either ISA or DOES */ |
87
|
|
|
|
|
|
|
}, |
88
|
|
|
|
|
|
|
); |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
With the minor exception of the 2 exception cases, passing |
91
|
|
|
|
|
|
|
an array ref, or a coderef, which internally are typecasted to |
92
|
|
|
|
|
|
|
L<Search::GIN::Extract::Attributes> and L<Search::GIN::Extract::Callback> |
93
|
|
|
|
|
|
|
automatically. |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 WARNING |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
This is an early release, API is prone to change without much warning, but best attempts will be made to avoid the need. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 ROLES |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 L<Search::GIN::Extract> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 extract_isa |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Applied on all objects where $object->isa( $classname ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head3 types: |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head4 HashRef[ L<Search::GIN::Extract::ClassMap::Types/Extractor> ] -> |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Types/CoercedClassMap> -> |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Isa> |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
HashRef's are automatically type-cast. |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=head2 extract_does |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
Applied on all objects where $object->does( $classname ); |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=head3 types: |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head4 HashRef[ L<Search::GIN::Extract::ClassMap::Types/Extractor> ] -> |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Types/CoercedClassMap> -> |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Does> |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
HashRef's are automatically type-cast. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 extract_does |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Applied on all objects where $object->does( $classname ) OR $object->isa( $classname ); |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
this doesn't make complete sense, but its handy for lazy people. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=head3 types: |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head4 HashRef[ L<Search::GIN::Extract::ClassMap::Types/Extractor> ] |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Types/CoercedClassMap> -> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=head4 L<Search::GIN::Extract::ClassMap::Like> |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
HashRef's are automatically type-cast. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 METHODS |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=head2 extract_values |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head3 for: L<Search::GIN::Extract> |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 AUTHOR |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Kent Fredric <kentnl@cpan.org> |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This software is copyright (c) 2013 by Kent Fredric. |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
164
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
=cut |