File Coverage

blib/lib/DBIx/Inspector/Iterator.pm
Criterion Covered Total %
statement 12 27 44.4
branch 0 6 0.0
condition 0 3 0.0
subroutine 4 7 57.1
pod 2 3 66.6
total 18 46 39.1


line stmt bran cond sub pod time code
1             package DBIx::Inspector::Iterator;
2 1     1   8 use strict;
  1         2  
  1         49  
3 1     1   27 use warnings;
  1         2  
  1         36  
4 1     1   6 use utf8;
  1         1  
  1         8  
5 1     1   52 use Class::Accessor::Lite;
  1         3  
  1         8  
6             Class::Accessor::Lite->mk_accessors(qw/sth callback skip_cb/);
7              
8             sub new {
9 0     0 0   my $class = shift;
10 0 0         my %args = @_ == 1 ? %{ $_[0] } : @_;
  0            
11 0           bless {%args}, $class;
12             }
13              
14             sub next {
15 0     0 1   my $self = shift;
16              
17 0 0         if (my $row = $self->sth->fetchrow_hashref('NAME_uc')) {
18 0 0 0       if ($self->skip_cb && $self->skip_cb->($row)) {
19 0           return $self->next();
20             }
21 0           $self->callback->($row);
22             } else {
23 0           return;
24             }
25             }
26              
27             sub all {
28 0     0 1   my $self = shift;
29 0           my @rows;
30 0           while (my $row = $self->next) {
31 0           push @rows, $row;
32             }
33 0           return @rows;
34             }
35              
36             1;
37             __END__