OpenSearch/Response/Tiny.pm

filter: Statementstmt 100% 20 / 20 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 96.5% 28 / 29 CC 4 SCAR 10.0
CC
4
Cov
96%
stringify
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« OpenSearch/Response.pm ↑ Summary OpenSearch/Response/JSON.pm »
1 package Search::OpenSearch::Response::Tiny;
2 2 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 extends 'Search::OpenSearch::Response::JSON';
5 2 ▶use JSON;
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 2 our $VERSION = '0.409';
8  
9 2 my %tiny_fields = map { $_ => 1 } qw(
10 total
11 facets
12 results
13 suggestions
14 version
15 );
16  
17 1 ▶sub stringify {
Subroutine stringify: called CC=4 SCAR=13.9
Pod documented
18 1 my $self = shift;
19  
20 1 my $resp = $self->as_hash;
21  
22 # delete everything but a select "min"imum
23 1 for my $k ( keys %$resp ) {
24 19 ▶ next if exists $tiny_fields{$k};
Branch: 1 branch
BranchTrueFalseTotal
if exists $tiny_fields{$k} 5 14 19
25 14 delete $resp->{$k};
26 }
27  
28 # in devel mode use pretty()
29 1 ▶ return $self->debug
Branch: 1 branch
BranchTrueFalseTotal
$self->debug ? : 0 1 1
30 ? JSON->new->utf8->pretty(1)->encode($resp)
31 : encode_json($resp);
32 }
33  
34 2 1;
35  
36 __END__
« OpenSearch/Response.pm ↑ Summary OpenSearch/Response/JSON.pm »