Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Data / Stream / Bulk / DBIC.pm
CommitLineData
3fea05b9 1#!/usr/bin/perl
2
3package Data::Stream::Bulk::DBIC;
4use Moose;
5
6use namespace::clean -except => 'meta';
7
8with qw(Data::Stream::Bulk::DoneFlag) => { excludes => [qw(is_done finished)] };
9
10has resultset => (
11 isa => "Object",
12 clearer => "finished",
13 handles => { next_row => "next" },
14 required => 1,
15);
16
17sub get_more {
18 my $self = shift;
19
20 if ( defined( my $next = $self->next_row ) ) {
21 return [ $next ];
22 } else {
23 return;
24 }
25}
26
27__PACKAGE__->meta->make_immutable;
28
29__PACKAGE__
30
31__END__
32
33=pod
34
35=head1 NAME
36
37Data::Stream::Bulk::DBIC - Iterate DBIC resultsets with L<Data::Stream::Bulk>
38
39=head1 SYNOPSIS
40
41 Data::Stream::Bulk::DBIC->new(
42 resultset => scalar($schema->rs("Foo")->search(...))
43 );
44
45=head1 DESCRIPTION
46
47This is a wrapper for L<DBIx::Class::ResultSet> that fits the
48L<Data::Stream::Bulk> api.
49
50Due to the fact that DBIC inflation overhead is fairly negligiable to that of
51iteration though, I haven't actually bothered to make it bulk.
52
53If L<DBIx::Class::Cursor> will support n-at-a-time fetching as opposed to
54one-at-a-time or all-at-a-time at some point in the future this class will be
55updated to match.
56
57=head1 METHODS
58
59=over 4
60
61=item get_more
62
63See L<Data::Stream::Bulk::DoneFlag>.
64
65Returns a single row. In the future this should return more than one row.
66
67=back
68
69=cut