File Coverage

blib/lib/Catmandu/IterableOnce.pm
Criterion Covered Total %
statement 6 6 100.0
branch n/a
condition n/a
subroutine 2 3 66.6
pod 0 1 0.0
total 8 10 80.0


line stmt bran cond sub pod time code
1             package Catmandu::IterableOnce;
2              
3 36     36   122612 use Catmandu::Sane;
  36         110  
  36         295  
4 36     36   343 use Moo::Role;
  36         104  
  36         444  
5              
6             has exhausted => (is => 'rwp', default => sub {0});
7              
8             around generator => sub {
9             my ($orig, $self) = @_;
10             return sub { }
11             if $self->exhausted;
12             $self->_set_exhausted(1);
13             $orig->($self);
14             };
15              
16       0 0   sub rewind { }
17              
18             1;
19              
20             __END__
21              
22             =pod
23              
24             =head1 NAME
25              
26             Catmandu::IterableOnce - Role for iterable classes that can only iterate once
27              
28             =head1 SYNOPSIS
29              
30             package MySingleUseIterator;
31             use Moo;
32             with 'Catmandu::Iterable';
33             with 'Catmandu::Iterableonce';
34              
35             sub generator {
36             # ...
37             }
38              
39             =head1 SEE ALSO
40              
41             L<Catmandu::Iterable>.
42              
43             =cut