line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MongoDBx::Tiny::Cursor; |
2
|
2
|
|
|
2
|
|
2832
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
56
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
MongoDBx::Tiny::Cursor - wrapper class of MongoDB::Cursor |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=cut |
9
|
|
|
|
|
|
|
|
10
|
2
|
|
|
2
|
|
6
|
use Carp qw(confess); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
626
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 new |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$cursor = MongoDBx::Tiny::Cursor->new( |
17
|
|
|
|
|
|
|
tiny => $tiny, c_name => $c_name,cursor => $cursor |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=cut |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub new { |
23
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
24
|
0
|
|
|
|
|
|
my %param = @_; |
25
|
0
|
|
|
|
|
|
return bless \%param, $class; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head2 all |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
@list = $cursor->all; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=cut |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub all { |
35
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
36
|
0
|
|
|
|
|
|
return map { $self->{tiny}->document_to_object($self->{c_name},$_) } $self->{cursor}->all; |
|
0
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 array |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
@list = $cursor->array; |
42
|
|
|
|
|
|
|
$list = $cursor->array; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub array { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
0
|
0
|
|
|
|
|
return wantarray ? $self->all:[$self->all]; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head2 next |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# get next object |
54
|
|
|
|
|
|
|
$object = $cursor->next; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=cut |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub next { |
59
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
60
|
0
|
|
|
|
|
|
my $document = $self->{cursor}->next; |
61
|
0
|
0
|
|
|
|
|
return unless $document; |
62
|
0
|
|
|
|
|
|
return $self->{tiny}->document_to_object($self->{c_name},$document); |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head2 first |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
[EXPERIMENTAL] |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
$first_object = $cursor->first; # just call next.. |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub first { |
74
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
75
|
|
|
|
|
|
|
# xxx |
76
|
0
|
|
|
|
|
|
$self->next; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub AUTOLOAD { |
80
|
0
|
|
|
0
|
|
|
my $self = shift; |
81
|
|
|
|
|
|
|
# xxx |
82
|
0
|
|
|
|
|
|
my $method = our $AUTOLOAD; |
83
|
0
|
|
|
|
|
|
$method =~ s/.*:://o; |
84
|
0
|
0
|
|
|
|
|
if ($method =~ /^(fields|sort|limit|skip|snapshot|hint)$/) { |
85
|
0
|
|
|
|
|
|
$self->{cursor}->$method(@_); |
86
|
0
|
|
|
|
|
|
return $self; |
87
|
|
|
|
|
|
|
} else { |
88
|
0
|
|
|
|
|
|
return $self->{cursor}->$method(@_); |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
|
93
|
|
|
|
0
|
|
|
sub DESTROY {} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
1; |
97
|
|
|
|
|
|
|
__END__ |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head1 AUTHOR |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Naoto ISHIKAWA, C<< <toona at seesaa.co.jp> >> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Copyright 2013 Naoto ISHIKAWA. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
108
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
109
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|