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