Bug 25548: Remove Apache rewrite directives that trigger redirects
[koha.git] / Koha / MetadataIterator.pm
bloba9fd162d274fa340d2dfa6c54ceef4f460b351f9
1 package Koha::MetadataIterator;
3 # This contains an iterator over biblio and authority records
5 # Copyright 2014 Catalyst IT
7 # This file is part of Koha.
9 # Koha is free software; you can redistribute it and/or modify it
10 # under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 3 of the License, or
12 # (at your option) any later version.
14 # Koha is distributed in the hope that it will be useful, but
15 # WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with Koha; if not, see <http://www.gnu.org/licenses>.
22 =head1 NAME
24 Koha::MetadataIterator - iterates over records
26 =head1 DESCRIPTION
28 This provides a fairly generic iterator that will return records provided
29 by a function.
31 =head1 SYNOPSIS
33 use Koha::MetadataIterator;
34 my $next_func = sub {
35 # something that'll return each record
37 my $iterator = Koha::MetadataIterator->new($next_func);
38 while ( my $record = $iterator->next() ) {
39 # do something with $record
42 =head1 METHODS
44 =cut
46 use Modern::Perl;
48 =head2 new
50 my $it = new($next_func);
52 Takes a function that will provide the next bit of data.
54 =cut
56 sub new {
57 my ( $class, $next_func ) = @_;
59 bless { next_func => $next_func, }, $class;
62 =head2 next()
64 Provides the next record.
66 =cut
68 sub next {
69 my ($self) = @_;
71 return $self->{next_func}->();