Add built local::lib
[catagits/Gitalist.git] / local-lib5 / lib / perl5 / Data / Stream / Bulk / DBIC.pm
1 #!/usr/bin/perl
2
3 package Data::Stream::Bulk::DBIC;
4 use Moose;
5
6 use namespace::clean -except => 'meta';
7
8 with qw(Data::Stream::Bulk::DoneFlag) => { excludes => [qw(is_done finished)] };
9
10 has resultset => (
11         isa => "Object",
12         clearer => "finished",
13         handles => { next_row => "next" },
14         required => 1,
15 );
16
17 sub 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
37 Data::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
47 This is a wrapper for L<DBIx::Class::ResultSet> that fits the
48 L<Data::Stream::Bulk> api.
49
50 Due to the fact that DBIC inflation overhead is fairly negligiable to that of
51 iteration though, I haven't actually bothered to make it bulk.
52
53 If L<DBIx::Class::Cursor> will support n-at-a-time fetching as opposed to
54 one-at-a-time or all-at-a-time at some point in the future this class will be
55 updated to match.
56
57 =head1 METHODS
58
59 =over 4
60
61 =item get_more
62
63 See L<Data::Stream::Bulk::DoneFlag>.
64
65 Returns a single row. In the future this should return more than one row.
66
67 =back
68
69 =cut