blib/lib/DR/Tarantool/Tuple/MsgPack.pm untested

filter: Statementstmt 0.0% 0 / 14 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 18 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 use utf8;
2 use strict;
3 use warnings;
4  
5 =head1 NAME
6  
7 DR::Tarantool::Tuple::MsgPack - a tuple container for L<DR::Tarantool> (v >= 1.6)
8  
9 =head1 SYNOPSIS
10  
11 my $tuple = new DR::Tarantool::Tuple::MsgPack::MsgPack([ 1, 2, 3]);
12 my $tuple = new DR::Tarantool::Tuple::MsgPack::MsgPack([ 1, 2, 3], $space);
13 my $tuple = unpack DR::Tarantool::Tuple::MsgPack::MsgPack([ 1, 2, 3], $space);
14  
15  
16 $tuple->next( $other_tuple );
17  
18 $f = $tuple->raw(0);
19  
20 $f = $tuple->name_field;
21  
22  
23 =head1 DESCRIPTION
24  
25 A tuple contains normalized (unpacked) fields. You can access the fields
26 by their indexes (see L<raw> function) or by their names (if they are
27 described in the space).
28  
29 Each tuple can contain references to L<next> tuple and L<iter>ator,
30 so that if the server returns more than one tuple, all of them
31 can be accessed.
32  
33 =head1 METHODS
34  
35 =cut
36  
37 package DR::Tarantool::Tuple::MsgPack;
38 use base qw(DR::Tarantool::Tuple);
39  
40 $Carp::Internal{ (__PACKAGE__) }++;
41  
42  
43 =head2 new
44  
45 A constructor.
46  
47 my $t = DR::Tarantool::Tuple::MsgPack->new([1, 2, 3]);
48 my $t = DR::Tarantool::Tuple::MsgPack->new([1, 2, 3], $space);
49  
50 =cut
51  
52 # sub new {
53 # my ($class, @args) = @_;
54 # return $class->SUPER::new(@args);
55 # }
56  
57  
58  
59 =head2 unpack
60  
61 Another way to construct a tuple.
62  
63 my $t = DR::Tarantool::Tuple::MsgPack->unpack([1, 2, 3], $space);
64  
65 =cut
66  
67  
68  
69 =head2 raw
70  
71 Return raw data from the tuple.
72  
73 my $array = $tuple->raw;
74  
75 my $field = $tuple->raw(0);
76  
77 =cut
78  
79  
80  
81 =head2 next
82  
83 Append or return the next tuple, provided there is more than one
84 tuple in the result set.
85  
86 my $next_tuple = $tuple->next;
87  
88 =cut
89  
90  
91  
92 =head2 iter
93  
94 Return an iterator object associated with the tuple.
95  
96  
97 my $iterator = $tuple->iter;
98  
99 my $iterator = $tuple->iter('MyTupleClass', 'new');
100  
101 while(my $t = $iterator->next) {
102 # the first value of $t and $tuple are the same
103 ...
104 }
105  
106 =head3 Arguments
107  
108 =over
109  
110 =item package (optional)
111  
112 =item method (optional)
113  
114 If 'package' and 'method' are present, $iterator->L<next> method
115 constructs objects using C<< $package->$method( $next_tuple ) >>
116  
117 If 'method' is not present and 'package' is present, the iterator
118 blesses the raw array with 'package'.
119  
120 =back
121  
122 =cut
123  
124  
125  
126 =head2 tail
127  
128 Return the tail of the tuple (array of unnamed fields). The function always
129 returns B<ARRAYREF> (as L<raw>).
130  
131 =cut
132  
133  
134  
135 =head1 COPYRIGHT AND LICENSE
136  
137 Copyright (C) 2011 Dmitry E. Oboukhov <unera@debian.org>
138 Copyright (C) 2011 Roman V. Nikolaev <rshadow@rambler.ru>
139  
140 This program is free software, you can redistribute it and/or
141 modify it under the terms of the Artistic License.
142  
143 =head1 VCS
144  
145 The project is placed git repo on github:
146 L<https://github.com/dr-co/dr-tarantool/>.
147  
148 =cut
149  
150 1;
151