use strict;
use warnings;
-use base qw/
- Class::Accessor::Grouped
- DBIx::Class::Cursor
-/;
-use mro 'c3';
+use base qw/DBIx::Class::Cursor/;
+
+use Try::Tiny;
+use namespace::clean;
__PACKAGE__->mk_group_accessors('simple' =>
- qw/sth/
+ qw/sth storage args attrs/
);
=head1 NAME
=head1 SYNOPSIS
my $cursor = $schema->resultset('CD')->cursor();
- my $first_cd = $cursor->next;
+
+ # raw values off the database handle in resultset columns/select order
+ my @next_cd_column_values = $cursor->next;
+
+ # list of all raw values as arrayrefs
+ my @all_cds_column_values = $cursor->all;
=head1 DESCRIPTION
my $new = {
storage => $storage,
args => $args,
- pos => 0,
attrs => $attrs,
_dbh_gen => $storage->{_dbh_gen},
+ _pos => 0,
+ _done => 0,
};
return bless ($new, $class);
if (
$self->{attrs}{software_limit}
&& $self->{attrs}{rows}
- && $self->{pos} >= $self->{attrs}{rows}
+ && $self->{_pos} >= $self->{attrs}{rows}
) {
$self->sth->finish if $self->sth->{Active};
$self->sth(undef);
- $self->{done} = 1;
+ $self->{_done} = 1;
}
- return if $self->{done};
+
+ return if $self->{_done};
+
unless ($self->sth) {
$self->sth(($storage->_select(@{$self->{args}}))[1]);
if ($self->{attrs}{software_limit}) {
}
my @row = $self->sth->fetchrow_array;
if (@row) {
- $self->{pos}++;
+ $self->{_pos}++;
} else {
$self->sth(undef);
- $self->{done} = 1;
+ $self->{_done} = 1;
}
return @row;
}
my ($self) = @_;
# No need to care about failures here
- eval { $self->sth->finish if $self->sth && $self->sth->{Active} };
+ try { $self->sth->finish }
+ if $self->sth && $self->sth->{Active};
$self->_soft_reset;
return undef;
}
my ($self) = @_;
$self->sth(undef);
- delete $self->{done};
- $self->{pos} = 0;
+ $self->{_done} = 0;
+ $self->{_pos} = 0;
}
sub _check_dbh_gen {
}
sub DESTROY {
- my ($self) = @_;
-
# None of the reasons this would die matter if we're in DESTROY anyways
- local $@;
- eval { $self->sth->finish if $self->sth && $self->sth->{Active} };
+ if (my $sth = $_[0]->sth) {
+ local $SIG{__WARN__} = sub {};
+ try { $sth->finish } if $sth->FETCH('Active');
+ }
}
1;