| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # ABSTRACT: ArangoDB Cursor object | 
| 2 |  |  |  |  |  |  | package Arango::DB::Cursor; | 
| 3 |  |  |  |  |  |  | $Arango::DB::Cursor::VERSION = '0.005'; | 
| 4 | 4 |  |  | 4 |  | 26 | use warnings; | 
|  | 4 |  |  |  |  | 8 |  | 
|  | 4 |  |  |  |  | 132 |  | 
| 5 | 4 |  |  | 4 |  | 19 | use strict; | 
|  | 4 |  |  |  |  | 8 |  | 
|  | 4 |  |  |  |  | 75 |  | 
| 6 |  |  |  |  |  |  |  | 
| 7 | 4 |  |  | 4 |  | 2519 | use Data::Dumper; | 
|  | 4 |  |  |  |  | 27731 |  | 
|  | 4 |  |  |  |  | 1083 |  | 
| 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 has_more { | 
| 38 | 0 |  |  | 0 | 1 |  | my ($self) = @_; | 
| 39 | 0 |  |  |  |  |  | return $self->{hasMore}; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 |  |  |  |  |  |  | 1; | 
| 43 |  |  |  |  |  |  |  | 
| 44 |  |  |  |  |  |  | __END__ |