NAME

OpenInteract2::ResultsIterator - Iterator to scroll through search results that are objects of different classes.

SYNOPSIS

my $results = OpenInteract2::ResultsManage->new(
                             { search_id => $search_id });
my $iter = $results->retrieve({ return => 'iterator' });
while ( my $obj = $iter->get_next ) {
    print "Object is a ", ref( $obj ), " with ID ", $obj->id, "\n";
}

DESCRIPTION

This class implements SPOPS::Iterator so we can scroll through search results one at a time.

Note that the objects it returns do not necessarily have to be SPOPS objects. At a minimum the class must implement:

  • fetch( $id ) - Return a new object

And the object must implement:

  • id() - Identify the object

METHODS

initialize( \%params )

See the SPOPS::Iterator method for the arguments to new(), which calls this method before returning the iterator.

Initializes the iterator with:

  • results - Arrayref of arrayrefs representing search results. Should be in the format:

    [ object class, object ID, extra data, extra data... ]

    where 'extra data' is just additional data, described by the extra_name parameter.

  • extra_name - Arrayref of names of extra data. If you have two additional entries per result you should have two names here.

  • min - Start returning results at this count.

  • max - Finish returning results at this count.

fetch_object

Returns the next object from the iterator. If called in list context returns a three-item list with: the returned object, place number of object in iterator, and a hashref with any additional data associated with the result.

SEE ALSO

SPOPS::Iterator

OpenInteract2::ResultsManage

COPYRIGHT

Copyright (c) 2001-2005 Chris Winters. All rights reserved.

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

AUTHORS

Chris Winters <chris@cwinters.com>