File Coverage

blib/lib/Bootylicious/IteratorSearchable.pm
Criterion Covered Total %
statement 24 24 100.0
branch 4 4 100.0
condition n/a
subroutine 5 5 100.0
pod 0 2 0.0
total 33 35 94.2


line stmt bran cond sub pod time code
1             package Bootylicious::IteratorSearchable;
2              
3 15     15   627 use strict;
  15         30  
  15         325  
4 15     15   63 use warnings;
  15         30  
  15         319  
5              
6 15     15   64 use base 'Bootylicious::Decorator';
  15         31  
  15         4168  
7              
8             sub find_first {
9 24     24 0 67 my $self = shift;
10 24         49 my $cb = shift;
11              
12 24         151 $self->rewind;
13              
14 24         116 while (my $el = $self->next) {
15 27 100       71 if (my $res = $cb->($self->object, $el)) {
16 15         159 return $res;
17             }
18             }
19              
20 9         96 return;
21             }
22              
23             sub find_all {
24 11     11 0 32 my $self = shift;
25 11         19 my $cb = shift;
26              
27 11         76 $self->rewind;
28              
29 11         22 my @found_elements;
30 11         51 while (my $el = $self->next) {
31 22 100       60 if (my $res = $cb->($self->object, $el)) {
32 10         65 push @found_elements, $res;
33             }
34             }
35              
36 11         56 return Bootylicious::Iterator->new(elements => [@found_elements]);
37             }
38              
39             1;