| 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
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | # FIXME: add validation. | ||||||||||||||||||||
| 19 | 1 | $self->{_object} = $opts{object}; | |||||||||||||||||||
| 20 | 1 | ▶ | $self->{_ids} = $opts{ids} || []; | ||||||||||||||||||
|
Condition50%1/2
$opts{'ids'} || []
MC/DC0%0/1
$opts{'ids'} || []
$opts{'ids'}
Truth table50%1/2
A
A= $opts{'ids'}
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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
| |||||||||||||||||||||
| 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__ | ||||||||||||||||||||