File Coverage

blib/lib/Search/GIN/Extract/ClassMap/Isa.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 34 36 94.4


line stmt bran cond sub pod time code
1 3     3   1504 use 5.006; # our
  3         9  
2 3     3   12 use strict;
  3         3  
  3         59  
3 3     3   11 use warnings;
  3         3  
  3         187  
4              
5             package Search::GIN::Extract::ClassMap::Isa;
6              
7             # ABSTRACT: Map Extractors based on an objects inheritance
8              
9             our $VERSION = '1.000003';
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 3     3   432 use Moose qw( with blessed );
  3         350523  
  3         51  
14 3     3   14249 use namespace::autoclean;
  3         6573  
  3         19  
15              
16             with 'Search::GIN::Extract::ClassMap::Role';
17              
18 3     3   249 no Moose;
  3         4  
  3         15  
19             __PACKAGE__->meta->make_immutable;
20              
21              
22              
23              
24              
25              
26              
27              
28              
29              
30              
31              
32              
33              
34             sub matches {
35 2     2 1 3 my ( $self, $extractee ) = @_;
36 2         3 my @m;
37 2 50       12 return @m if not blessed $extractee;
38 2         113 for my $class ( $self->classmap_entries ) {
39 1 50       8 if ( $extractee->isa($class) ) {
40 1         62 push @m, $self->classmap_get($class);
41             }
42             }
43 2         9 return @m;
44             }
45              
46             1;
47              
48             __END__
49              
50             =pod
51              
52             =encoding UTF-8
53              
54             =head1 NAME
55              
56             Search::GIN::Extract::ClassMap::Isa - Map Extractors based on an objects inheritance
57              
58             =head1 VERSION
59              
60             version 1.000003
61              
62             =head1 METHODS
63              
64             =head2 C<matches>
65              
66             # List of Search::GIN::Extract objects
67             my ( @extractors ) = $isa_object->matches( $extractee );
68              
69             returns a list of extractors that are in the map for the object.
70              
71             for my $extractor ( @extractors ) {
72             my $metadata = $extractor->extract_values( $extractee );
73             }
74              
75             =head1 AUTHOR
76              
77             Kent Fredric <kentnl@cpan.org>
78              
79             =head1 COPYRIGHT AND LICENSE
80              
81             This software is copyright (c) 2017 by Kent Fredric <kentfredric@gmail.com>.
82              
83             This is free software; you can redistribute it and/or modify it under
84             the same terms as the Perl 5 programming language system itself.
85              
86             =cut