C:\cpanrun\depot\main\contrib-patched\perl\CPAN\src\Data-ConveyorBelt\blib/lib/Data/ConveyorBelt.pm


NAME

Data::ConveyorBelt


SYNOPSIS

    my $machine = Data::ConveyorBelt->new;
    $machine->getter( sub {
        my( $limit, $offset ) = @_;
        my $data = ...
        return $data;
    } );
    $machine->add_filter( sub {
        my( $data ) = @_;
        ...
        return $data;
    } );
    
    my $data = $machine->fetch( limit => 5 );


DESCRIPTION


USAGE

Data::ConveyorBelt->new

Returns a new Data::ConveyorBelt instance.

$machine->getter( [ \&getter ] )

Gets/sets the getter subroutine \&getter that represents the list of items in your data source. Required before calling fetch.

A getter subroutine will be passed two arguments: the number of items to return, and the offset into the list (0-based). It must return a reference to the matching list of items.

$machine->add_filter( \&filter )

Adds a filter subroutine \&filter to your chain of filters.

A filter will be passed a reference to a list of items as returned either from your getter or from a previous filter in the chain. A filter must return a reference to a list of items.

A filter can alter the size of the list of items, either removing or expanding items in the list. It can also transform the items in the list.

$machine->fetch( %param )

Fetches a list of items from your data source, passes them through your filters, and returns a reference to a list of items.

You must install a getter before calling fetch, but you don't have to install any filters. Running fetch without any filters does what you'd expect: it returns the values directly from your data source, unmodified and unfiltered.

%param can contain:


LICENSE

Data::ConveyorBelt is free software; you may redistribute it and/or modify it under the same terms as Perl itself.


AUTHOR & COPYRIGHT

Except where otherwise noted, Data::ConveyorBelt is Copyright 2007 Six Apart, cpan@sixapart.com.