Christopher H. Laco > Handel-Storage-RDBO-1.00003 > Handel::Iterator::RDBO

Download:
Handel-Storage-RDBO-1.00003.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Source  

NAME ^

Handel::Iterator::RDBO - Iterator class used for collection looping RDBO resultsets

SYNOPSIS ^

    my $resultset = Rose::DBO::Object::Manager->get_objects(
        object_class => 'MySchemaClass'
    );
    
    my $iterator = Handel::Iterator::RDBO->new({
        data         => $resultset,
        result_class => 'MyResult',
        storage      => $storage
    });
    
    while (my $result = $iterator->next) {
        print $result->method;
    };

DESCRIPTION ^

Handel::Iterator::RDBO is a used to iterate through results stored in a resultset returned from Rose::DB::Object::Manager queries.

CONSTRUCTOR ^

new

Arguments: \%options

Creates a new iterator object. The following options are available:

    my $resultset = Rose::DBO::Object::Manager->get_objects(
        object_class => 'MySchemaClass'
    );
    
    my $iterator = Handel::Iterator::RDBO->new({
        data         => $resultset,
        result_class => 'MyResult',
        storage      => $storage
    });

    my $result = $iterator->first;
    print ref $result; # MyResult
data

The data to be iterated through. This should be an array ref returned from Rose::DB::Object::Manager methods like get_objects.

result_class

The name of the class that each result should be inflated into.

storage

The storage object that was used to create the results.

METHODS ^

all

Returns all results from current iterator.

    foreach my $result ($iterator->all) {
        print $result->method;
    };

count

Returns the number of results in the current iterator.

    my $count = $iterator->count;

create_result

Arguments: $result [, $storage]

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.

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

Returns the first result or undef if there are no results.

    my $first = $iterator->first;

last

Returns the last result or undef if there are no results.

    my $last = $iterator->last;

next

Returns the next result or undef if there are no results.

    while (my $result = $iterator->next) {
        print $result->method;
    };

reset

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;
    };

SEE ALSO ^

Handel::Iterator::List, Handel::Iterator

AUTHOR ^

    Christopher H. Laco
    CPAN ID: CLACO
    claco@chrislaco.com
    http://today.icantfocus.com/blog/
syntax highlighting: