NAME
Class::PObject::Iterator - Incremental object loader for Class::PObject
SYNOPSIS
use Class::PObject::Iterator;
my $iter = new Class::PObject::Iterator($class, \@ids);
while ( my $obj = $iter->fetch ) {
...
}
DESCRIPTION
Class::PObject::Iterator is a stand-alone iterator class initially used by Class::PObject when you call fetch()
method on a pobject.
METHODS
new($class, \@ids)
-
Constructor method. Accepts two arguments - name of the class, and list of ids. Returns Class::PObject::Iterator object. You normally never will have to call
new()
yourself, because when you callfetch()
method on your $pobject it will return pre-initialized iterator object. next()
-
When called on an iterator object, it will return the next object from the stack. Remember, it will not return the object id, but it will return fully initialized pobject.
size()
-
Returns size of the current stack. This number decrements by one each time
next()
is called, to reflect how many more elements are left in the data set. reset()
-
Resets the internal data set pointer to the beginning of the data set. This means, no matter how far you have been into the stack, after you call
reset()
, the next time you callnext()
method, it will return the object from the beginning of the stack. push($idx)
-
Pushes a new object id to the end of the current stack.
finish()
-
Clears up the stack and other related data from the object.
finish()
will be called for you automatically once the iterator object exits the scope. You normally will not need to call this method, for iterator object clears up all the remaining stack before it exits its scope. However, this method may be handy if you are planning topush()
more data sets to the iterator object and want to start from clean data set:$iterator->finish(); for ( @inx ) { $iterator->push($_) }
SEE ALSO
COPYRIGHT AND LICENSE
For author and copyright information refer to Class::PObject's online manual.