REST/SearchResult.pm

filter: Statementstmt 100% 32 / 32 Branchbran 83.3% 5 / 6 Conditioncond 40.0% 2 / 5 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 100% 7 / 7 Podpod 100% 3 / 3 totaltotal 87.5% 49 / 56 CC 6 SCAR 8.0
CC
6
Cov
91%
new
3.2
__ANON__
3.0
_retrieve
2.0
CRAP 2.2
« REST/HTTPClient.pm ↑ Summary REST/Ticket.pm »
1 #!perl
2 # vim: softtabstop=4 tabstop=4 shiftwidth=4 ft=perl expandtab smarttab
3 # PODNAME: RT::Client::REST::SearchResult
4 # ABSTRACT: search results object.
5  
6 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 package RT::Client::REST::SearchResult;
10 17 $RT::Client::REST::SearchResult::VERSION = '0.73';
11 1 ▶sub new {
Subroutine new: called CC=3 SCAR=11.6
Pod documented
12 1 my $class = shift;
13  
14 1 my %opts = @_;
15  
16 1 ▶ my $self = bless {}, ref($class) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
010
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
17  
18 # FIXME: add validation.
19 1 $self->{_object} = $opts{object};
20 1 ▶ $self->{_ids} = $opts{ids} || [];
Condition50%1/2
$opts{'ids'} || []
l!l
10
MC/DC0%0/1
$opts{'ids'} || []
$opts{'ids'}
Truth table50%1/2
A
A= $opts{'ids'}
Aresult
11
00
21  
22 1 return $self;
23 }
24  
25 1 ▶sub count { scalar( @{ shift->{_ids} } ) }
Subroutine count: called CC=1 SCAR=0.0
Pod documented
26  
27 18 ▶sub _retrieve {
Subroutine _retrieve: called CC=2 SCAR=7.0
28 18 my ( $self, $obj ) = @_;
29  
30 18 ▶ unless ( $obj->autoget ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($obj->autoget) 18 0 18
31 18 $obj->retrieve;
32 }
33  
34 18 return $obj;
35 }
36  
37 2 ▶sub get_iterator {
Subroutine get_iterator: called CC=1 SCAR=0.0
Pod documented
38 2 my $self = shift;
39 2 my @ids = @{ $self->{_ids} };
40 2 my $object = $self->{_object};
41  
42 12 ▶ return sub {
Subroutine __ANON__: called CC=3 SCAR=11.0
43 12 ▶ if (wantarray) {
Branch: 2 branches
BranchTrueFalseTotal
if (wantarray) { } 2 10 12
elsif (@ids) { } 9 1 10
44 2 my @tomap = @ids;
45 2 @ids = ();
46  
47 2 return map { $self->_retrieve( $object->($_) ) } @tomap;
48 }
49 elsif (@ids) {
50 9 return $self->_retrieve( $object->( shift(@ids) ) );
51 }
52 else {
53 1 return; # This signifies the end of the iterations
54 }
55 2 };
56 }
57  
58 17 1;
59  
60 __END__
« REST/HTTPClient.pm ↑ Summary REST/Ticket.pm »