| 1 | package Catmandu::MultiIterator; | ||||||||||
| 2 | |||||||||||
| 3 | 2 | ▶ | use Catmandu::Sane; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | 2 | our $VERSION = '1.0201_02'; | |||||||||
| 6 | |||||||||||
| 7 | 2 | ▶ | use Role::Tiny::With; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 2 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | 2 | with 'Catmandu::Iterable'; | |||||||||
| 11 | |||||||||||
| 12 | sub new { | ||||||||||
| 13 | 1 | ▶ | my ($class, @iterators) = @_; | ||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 14 | 1 | my $self = \@iterators; | |||||||||
| 15 | 1 | bless $self, $class; | |||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub generator { | ||||||||||
| 19 | 1 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
generator: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 20 | sub { | ||||||||||
| 21 | 7 | ▶ | state $generators = [map {$_->generator} @$self]; | ||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.0
| |||||||||||
| 22 | 7 | ▶ | while (@$generators) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 23 | 8 | my $data = $generators->[0]->(); | |||||||||
| 24 | 8 | ▶ | return $data if defined $data; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | 2 | shift @$generators; | |||||||||
| 26 | } | ||||||||||
| 27 | 1 | return; | |||||||||
| 28 | 1 | }; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | 1; | |||||||||
| 32 | |||||||||||
| 33 | __END__ | ||||||||||
| 34 | |||||||||||
| 35 | =pod | ||||||||||
| 36 | |||||||||||
| 37 | =head1 NAME | ||||||||||
| 38 | |||||||||||
| 39 | Catmandu::MultiIterator - chain multiple iterators together | ||||||||||
| 40 | |||||||||||
| 41 | =head1 SYNOPSIS | ||||||||||
| 42 | |||||||||||
| 43 | my $it = Catmandu::MultiIterator->new( | ||||||||||
| 44 | Catmandu::Importer::Mock->new, | ||||||||||
| 45 | Catmandu::Importer::Mock->new, | ||||||||||
| 46 | ); | ||||||||||
| 47 | |||||||||||
| 48 | # return all the items of each importer in turn | ||||||||||
| 49 | $it->each(sub { | ||||||||||
| 50 | # ... | ||||||||||
| 51 | }); | ||||||||||
| 52 | |||||||||||
| 53 | =head1 METHODS | ||||||||||
| 54 | |||||||||||
| 55 | All L<Catmandu::Iterable> methods are available. | ||||||||||
| 56 | |||||||||||
| 57 | =cut | ||||||||||