NAME

DBIx::QuickORM::Iterator - Lazy, caching iterator over a generator.

DESCRIPTION

Wraps a generator coderef that yields one item per call and returns undef when exhausted. Items are pulled on demand and cached, so the iterator can be walked, reset, and re-walked. An optional readiness coderef supports async result checks.

SYNOPSIS

my $iter = DBIx::QuickORM::Iterator->new(\&generator, \&ready);

while (defined(my $item = $iter->next)) { ... }

my @all = $iter->list;

ATTRIBUTES

generator

Coderef yielding one item per call, undef when exhausted.

items

Arrayref of items pulled from the generator so far.

generator_done

True once the generator has signalled exhaustion.

index

Current position for next.

ready

Optional coderef returning true once results are available.

PUBLIC METHODS

$item = $iter->next

Return the next item and advance, or undef when exhausted.

$item = $iter->first

Reset to the start and return the first item.

$item = $iter->last

Exhaust the generator and return the last item (or undef if none).

@items = $iter->list

Exhaust the generator and return every item.

$bool = $iter->ready

True when results are available. Always true unless a readiness coderef was supplied.

SOURCE

The source code repository for DBIx::QuickORM can be found at https://github.com/exodist/DBIx-QuickORM.

MAINTAINERS

Chad Granum <exodist@cpan.org>

AUTHORS

Chad Granum <exodist@cpan.org>

COPYRIGHT

Copyright Chad Granum <exodist7@gmail.com>.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

See https://dev.perl.org/licenses/