GIN/Extract/Attributes.pm

filter: Statementstmt 87.1% 27 / 31 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 2 totaltotal 81.4% 35 / 43 CC 3 SCAR 4.7
CC
3
Cov
83%
get_meta_attrs
2.4
extract_values
2.0
BEGIN
1.0
CRAP 1.6
« GIN/Extract/Class.pm ↑ Summary GIN/Query/Manual.pm »
1 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 package Search::GIN::Extract::Attributes;
4  
5 1 our $VERSION = '0.11';
6  
7 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use namespace::autoclean;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 1 with qw(
11 Search::GIN::Extract
12 Search::GIN::Keys::Deep
13 );
14  
15 1 has attributes => (
16 isa => "ArrayRef[Str]",
17 is => "rw",
18 predicate => "has_attributes",
19 );
20  
21 3 ▶sub extract_values {
Subroutine extract_values: called CC=2 SCAR=7.0
Pod undocumented
22 3 my ( $self, $obj, @args ) = @_;
23  
24 3 my @meta_attrs = $self->get_meta_attrs($obj, @args);
25  
26 return $self->process_keys({ map {
27 3 my $val = $_->get_value($obj);
28 6 ▶ $_->name => (defined($val) ? $val : undef);
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 6 0 6
29 } @meta_attrs });
30 }
31  
32 3 ▶sub get_meta_attrs {
Subroutine get_meta_attrs: called CC=2 SCAR=8.7
Pod undocumented
33 3 my ( $self, $obj, @args ) = @_;
34  
35 3 my $class = ref $obj;
36 3 my $meta = Class::MOP::get_metaclass_by_name($class);
37  
38 3 ▶ if ( $self->has_attributes ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->has_attributes) { } 0 3 3
39 0 return grep { defined } map { $meta->find_attribute_by_name($_) } @{ $self->attributes };
40 } else {
41 3 return $meta->get_all_attributes;
42 }
43 }
44  
45 1 __PACKAGE__->meta->make_immutable;
46  
47 1 1;
« GIN/Extract/Class.pm ↑ Summary GIN/Query/Manual.pm »