File Coverage

blib/lib/Search/GIN/Extract/ClassMap/Does.pm
Criterion Covered Total %
statement 22 24 91.6
branch 1 4 25.0
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 31 36 86.1


line stmt bran cond sub pod time code
1 3     3   1772 use 5.006; # our
  3         9  
2 3     3   14 use strict;
  3         4  
  3         68  
3 3     3   23 use warnings;
  3         4  
  3         228  
4              
5             package Search::GIN::Extract::ClassMap::Does;
6              
7             # ABSTRACT: Map Extractors based on an objects roles.
8              
9             our $VERSION = '1.000003';
10              
11             our $AUTHORITY = 'cpan:KENTNL'; # AUTHORITY
12              
13 3     3   721 use Moose qw( with blessed );
  3         349549  
  3         18  
14 3     3   12386 use namespace::autoclean;
  3         5969  
  3         20  
15              
16             with 'Search::GIN::Extract::ClassMap::Role';
17              
18 3     3   231 no Moose;
  3         4  
  3         16  
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 5 my ( $self, $extractee ) = @_;
36 2         5 my @m;
37 2 50       12 return @m if not blessed $extractee;
38 2         125 for my $class ( $self->classmap_entries ) {
39 0 0       0 if ( $extractee->does($class) ) {
40 0         0 push @m, $self->classmap_get($class);
41             }
42             }
43 2         7 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::Does - Map Extractors based on an objects 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 ) = $does_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