File Coverage

blib/lib/FormValidator/Simple/Iterator.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 2 100.0
condition n/a
subroutine 5 5 100.0
pod 0 3 0.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package FormValidator::Simple::Iterator;
2 24     24   196 use strict;
  24         46  
  24         6527  
3              
4             sub new {
5 158     158 0 251 my $class = shift;
6 158         457 my $self = bless { }, $class;
7 158         533 $self->_init(@_);
8 158         454 return $self;
9             }
10              
11             sub _init {
12 158     158   223 my ($self, $records) = @_;
13 158         548 $self->{_index} = 0;
14 158         332 $self->{_records} = $records;
15             }
16              
17             sub reset {
18 1     1 0 5394 my $self = shift;
19 1         5 $self->{_index} = 0;
20             }
21              
22             sub next {
23 365     365 0 3745 my $self = shift;
24 365 100       1222 return unless ($self->{_records}->records_count > $self->{_index});
25 217         1946 my $record = $self->{_records}->get_record_at($self->{_index});
26 217         1094 $self->{_index}++;
27 217         850 return $record;
28             }
29              
30             1;
31             __END__