line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Mandel::Iterator; |
2
|
20
|
|
|
20
|
|
136
|
use Mojo::Base -base; |
|
20
|
|
|
|
|
50
|
|
|
20
|
|
|
|
|
151
|
|
3
|
20
|
|
|
20
|
|
3011
|
use Scalar::Util 'blessed'; |
|
20
|
|
|
|
|
56
|
|
|
20
|
|
|
|
|
1031
|
|
4
|
20
|
|
|
20
|
|
159
|
use Carp 'confess'; |
|
20
|
|
|
|
|
46
|
|
|
20
|
|
|
|
|
7611
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
require Mandel::Collection; # TODO: Fix ugly method call below |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
has cursor => sub { confess "cursor required in constructor" }; |
9
|
|
|
|
|
|
|
has model => sub { confess "model required in constructor" }; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub next { |
12
|
0
|
|
|
0
|
1
|
|
my ($self, $cb) = @_; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
$self->cursor->next( |
15
|
|
|
|
|
|
|
sub { |
16
|
0
|
|
|
0
|
|
|
my ($cursor, $err, $doc) = @_; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# TODO: Fix this ugly method call |
19
|
0
|
0
|
|
|
|
|
$self->$cb($err, $doc ? $self->Mandel::Collection::_new_document($doc, 1) : undef); |
20
|
|
|
|
|
|
|
} |
21
|
0
|
|
|
|
|
|
); |
22
|
|
|
|
|
|
|
|
23
|
0
|
|
|
|
|
|
$self; |
24
|
|
|
|
|
|
|
} |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub rewind { |
27
|
0
|
|
|
0
|
1
|
|
my ($self, $cb) = @_; |
28
|
|
|
|
|
|
|
|
29
|
0
|
0
|
|
|
|
|
if ($self->{cursor}) { |
30
|
|
|
|
|
|
|
$self->cursor->rewind( |
31
|
|
|
|
|
|
|
sub { |
32
|
0
|
|
|
0
|
|
|
$self->$cb($_[1]); |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
else { |
37
|
0
|
|
|
|
|
|
$self->$cb(''); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
0
|
|
|
|
|
|
$self; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=encoding utf8 |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 NAME |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Mandel::Iterator - An object iterating over a collection cursor |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 SYNOPSIS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 DESCRIPTION |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=head2 cursor |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
An object we can do C on. Normally a L object. |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head2 model |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
An object that inherit from L. |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 next |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$self = $self->next(sub { my($self, $err, $obj) = @_; ... }); |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Fetch next document. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 rewind |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$self = $self->rewind($cb); |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
Rewind cursor and kill it on the server |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head1 SEE ALSO |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
L, L, L |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 AUTHOR |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Jan Henning Thorsen - C |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=cut |