| 1 | package Catmandu::Iterator; | ||
| 2 | |||
| 3 | 47 | ▶ | use Catmandu::Sane; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 47 | our $VERSION = '1.0201_02'; | |
| 6 | |||
| 7 | 47 | ▶ | use Role::Tiny::With; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 47 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | |||
| 10 | 47 | with 'Catmandu::Iterable'; | |
| 11 | |||
| 12 | sub new { | ||
| 13 | 58 | ▶ | bless $_[1], $_[0]; |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||
| 14 | } | ||
| 15 | |||
| 16 | sub generator { | ||
| 17 | 55 | ▶ | goto &{$_[0]}; |
|
Subroutine
generator: called CC=1 SCAR=0.0
Pod
documented
| |||
| 18 | } | ||
| 19 | |||
| 20 | 47 | 1; | |
| 21 | |||
| 22 | __END__ | ||
| 23 | |||
| 24 | =pod | ||
| 25 | |||
| 26 | =head1 NAME | ||
| 27 | |||
| 28 | Catmandu::Iterator - Base class for all Catmandu iterators | ||
| 29 | |||
| 30 | =head1 SYNOPSIS | ||
| 31 | |||
| 32 | package My::MockIterator; | ||
| 33 | |||
| 34 | use Moo; | ||
| 35 | |||
| 36 | with 'Catmandu::Iterable'; | ||
| 37 | |||
| 38 | sub generator { | ||
| 39 | sub { | ||
| 40 | # Generator some random data | ||
| 41 | +{ random => rand }; | ||
| 42 | } | ||
| 43 | } | ||
| 44 | |||
| 45 | package main; | ||
| 46 | |||
| 47 | my $it = My::MockIterator->new; | ||
| 48 | |||
| 49 | my first = $it->first; | ||
| 50 | |||
| 51 | $it->each(sub { | ||
| 52 | my $item = shift; | ||
| 53 | |||
| 54 | print $item->{random} , "\n"; | ||
| 55 | }); | ||
| 56 | |||
| 57 | my $it2 = $it->map(sub { shift->{random} * 2 }); | ||
| 58 | |||
| 59 | =head1 METHODS | ||
| 60 | |||
| 61 | =head2 generator | ||
| 62 | |||
| 63 | Should return a closure that generates one Perl hash. | ||
| 64 | |||
| 65 | =head1 INHERIT | ||
| 66 | |||
| 67 | If you provide a generator, then the class will generator all methods from L<Catmandu::Iterable>. | ||
| 68 | |||
| 69 | =head1 SEE ALSO | ||
| 70 | |||
| 71 | L<Catmandu::Iterable> | ||
| 72 | |||
| 73 | =cut | ||