logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

Catmandu::Iterator - Base class for all Catmandu iterators

Inherit

       If you provide a generator, then the class will generator all methods from Catmandu::Iterable.

Methods

generator
       Should return a closure that generates one Perl hash.

Name

       Catmandu::Iterator - Base class for all Catmandu iterators

See Also

       Catmandu::Iterable

perl v5.40.0                                       2025-01-17                            Catmandu::Iterator(3pm)

Synopsis

         package My::MockIterator;

         use Catmandu;
         use Moo;

         with 'Catmandu::Iterable';

         sub generator {
           sub {
               # Generator some random data
               +{ random => rand };
           }
         }

         package main;

         my $it = My::MockIterator->new;

         my $first = $it->first;

         $it->each(sub {
         my $item = shift;

         print $item->{random} , "\n";
         });

         my $it2 = $it->map(sub { shift->{random} * 2 });

See Also