File Coverage

blib/lib/Arango/DB/Cursor.pm
Criterion Covered Total %
statement 9 28 32.1
branch 0 6 0.0
condition 0 3 0.0
subroutine 3 7 42.8
pod 3 3 100.0
total 15 47 31.9


line stmt bran cond sub pod time code
1             # ABSTRACT: ArangoDB Cursor object
2             package Arango::DB::Cursor;
3             $Arango::DB::Cursor::VERSION = '0.006';
4 5     5   35 use warnings;
  5         9  
  5         227  
5 5     5   26 use strict;
  5         10  
  5         106  
6              
7 5     5   3126 use Data::Dumper;
  5         37080  
  5         1739  
8              
9             sub _new {
10 0     0     my ($class, %opts) = @_;
11 0           my $self = { arango => $opts{arango}, database => $opts{database} };
12              
13 0           my $ans = $self->{arango}->_api('create_cursor', \%opts);
14              
15 0           return bless { %$ans, %$self, __current => 0 } => $class;
16             }
17              
18             sub next {
19 0     0 1   my $self = shift;
20              
21 0 0 0       if (!$self->{error} && $self->{__current} == 0) {
22 0           $self->{__current}++;
23 0           return $self->{result};
24             }
25              
26 0 0         if ($self->{hasMore}) {
27 0           my $ans = $self->{arango}->_api('cursor_next', { database => $self->{database}, id => $self->{id} });
28 0 0         if (!$ans->{error}) {
29 0           $self->{hasMore} = $ans->{hasMore};
30 0           return $ans->{result};
31             }
32             }
33              
34 0           return undef;
35             }
36              
37             sub finish {
38 0     0 1   my ($self) = @_;
39 0           $self->{arango}->_api('cursor_delete', { database => $self->{database}, id => $self->{id} });
40 0           delete $self->{$_} for (keys %$self);
41             }
42              
43             sub has_more {
44 0     0 1   my ($self) = @_;
45 0           return $self->{hasMore};
46             }
47              
48             1;
49              
50             __END__