File: Iterator.pm

package info (click to toggle)
libdbd-mock-perl 1.43-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 416 kB
  • sloc: perl: 1,135; makefile: 2
file content (22 lines) | stat: -rw-r--r-- 404 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package DBD::Mock::StatementTrack::Iterator;

use strict;
use warnings;

sub new {
    my ( $class, $history ) = @_;
    bless {
        pointer => 0,
        history => $history || []
    } => $class;
}

sub next {
    my ($self) = @_;
    return unless $self->{pointer} < scalar( @{ $self->{history} } );
    return $self->{history}->[ $self->{pointer}++ ];
}

sub reset { (shift)->{pointer} = 0 }

1;