File Coverage

blib/lib/Search/GIN/Extract/ClassMap/Like.pm
Criterion Covered Total %
statement 24 24 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 7 7 100.0
pod 1 1 100.0
total 35 39 89.7


line stmt bran cond sub pod time code
1 3     3   1864 use 5.006; # our
  3         8  
2 3     3   13 use strict;
  3         3  
  3         70  
3 3     3   12 use warnings;
  3         4  
  3         238  
4              
5             package Search::GIN::Extract::ClassMap::Like;
6              
7             # ABSTRACT: Map Extractors based on what an objects inheritance or roles
8              
9             our $VERSION = '1.000003';
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 3     3   650 use Moose qw( with blessed );
  3         358447  
  3         34  
14 3     3   14747 use namespace::autoclean;
  3         9023  
  3         21  
15              
16             with 'Search::GIN::Extract::ClassMap::Role';
17              
18 3     3   188 no Moose;
  3         5  
  3         19  
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 4 my ( $self, $extractee ) = @_;
36 2         3 my @m;
37 2 50       10 return @m if not blessed $extractee;
38 2         114 for my $class ( $self->classmap_entries ) {
39 2 50 33     11 if ( $extractee->isa($class) or $extractee->does($class) ) {
40 2         114 push @m, $self->classmap_get($class);
41             }
42             }
43 2         48 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::Like - Map Extractors based on what an objects inheritance or roles
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 ) = $like_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