Handel::Iterator - Iterator base class used for collection looping
my $iterator = Handel::Iterator::Custom->new({ data => [$object1, $object2, ...], result_class => 'MyResult', storage => $storage }); while (my $result = $iterator->next) { print $result->method; };
Handel::Iterator is a base class used to create custom iterators for DBIx::Class resultsets and lists of results.
Creates a new iterator object. The following options are available:
my $iterator = Handel::Iterator::Custom->new({ data => [$object1, $object2, ...], result_class => 'MyResult', storage => $storage }); my $result = $iterator->first; print ref $result; # MyResult
The data to be iterated through. The type of this data depends on the individual subclass.
The name of the class that each result should be inflated into.
The storage object that was used to create the results.
Returns all results from current iterator.
foreach my $result ($iterator->all) { print $result->method; };
Returns the number of results in the current iterator.
my $count = $iterator->count;
Returns a new result class object based on the specified result and storage objects. If no storage object is specified, the storage object passed to new will be used instead.
new
This method is used by methods like first and next to to create storage result objects. There is probably no good reason to use this method directly.
first
next
Returns the first result or undef if there are no results.
my $first = $iterator->first;
Returns the last result or undef if there are no results.
my $last = $iterator->last;
Returns the next result or undef if there are no results.
while (my $result = $iterator->next) { print $result->method; };
Resets the current result position back to the first result.
while (my $result = $iterator->next) { print $result->method; }; $iterator->reset; while (my $result = $iterator->next) { print $result->method; };
Handel::Iterator::DBIC, Handel::Iterator::List
Christopher H. Laco CPAN ID: CLACO claco@chrislaco.com http://today.icantfocus.com/blog/
To install Handel, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Handel
CPAN shell
perl -MCPAN -e shell install Handel
For more information on module installation, please visit the detailed CPAN module installation guide.