lib/DR/Tnt/Msgpack/Types.pm

filter: Statementstmt 100% 34 / 34 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 100% 6 / 6 totaltotal 100% 54 / 54 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/DR/Tnt/LowLevel.pm ↑ Summary
1 11 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 11 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 11 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DR::Tnt::Msgpack::Types;
6 11 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 11 ▶use DR::Tnt::Msgpack::Types::Int;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 11 ▶use DR::Tnt::Msgpack::Types::Str;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 11 ▶use DR::Tnt::Msgpack::Types::Blob;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 11 ▶use DR::Tnt::Msgpack::Types::Bool;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 11 our %EXPORT_TAGS = (
14 'all' => [
15 'mp_int',
16 'mp_bool',
17 'mp_string',
18 'mp_blob',
19  
20 'mp_true',
21 'mp_false',
22 ]
23 );
24  
25 11 our @EXPORT_OK = @{ $EXPORT_TAGS{all} };
26  
27  
28 sub mp_int($) {
29 19 ▶ DR::Tnt::Msgpack::Types::Int->new($_[0]);
Subroutine mp_int: called CC=1 SCAR=0.0
Pod documented
30 }
31 sub mp_string($) {
32 23 ▶ DR::Tnt::Msgpack::Types::Str->new($_[0]);
Subroutine mp_string: called CC=1 SCAR=0.0
Pod documented
33 }
34 sub mp_blob($) {
35 13 ▶ DR::Tnt::Msgpack::Types::Blob->new($_[0]);
Subroutine mp_blob: called CC=1 SCAR=0.0
Pod documented
36 }
37  
38 sub mp_bool($) {
39 4 ▶ DR::Tnt::Msgpack::Types::Bool->new($_[0]);
Subroutine mp_bool: called CC=1 SCAR=0.0
Pod documented
40 }
41 sub mp_true() {
42 10 ▶ DR::Tnt::Msgpack::Types::Bool->new(1);
Subroutine mp_true: called CC=1 SCAR=0.0
Pod documented
43 }
44 sub mp_false() {
45 8 ▶ DR::Tnt::Msgpack::Types::Bool->new(0);
Subroutine mp_false: called CC=1 SCAR=0.0
Pod documented
46 }
47  
48 =head1 NAME
49  
50 DR::Tnt::Msgpack::Types - types for msgpack.
51  
52 =head1 SYNOPSIS
53  
54 use DR::Tnt::Msgpack::Types;
55  
56 # pack as msgpack INT
57 msgpack(mp_int(123));
58  
59 # pack number as string
60 msgpack(mp_string(123));
61  
62 # bools
63 msgpack(mp_true);
64 msgpack(mp_false);
65 msgpack(mp_bool(1));
66 msgpack(mp_bool(0));
67  
68  
69 # blob
70 msgpack(mp_blob $blob);
71  
72  
73 =head1 DESCRIPTION
74  
75 Perl doesn't differ C<123> and C<'123'>:
76  
77 msgpack(123);
78 msgpack('123'); # the same
79  
80 From time to time You want to pack numbers as strings (for example You
81 use tarantool's STR-index for user's texts, that contain numbers, too).
82  
83 So You can use C<mp_string($)> constructor for L<DR::Tnt::Msgpack::Types::Str>.
84  
85 =head1 METHODS
86  
87 =over
88  
89 =item mp_int($)
90  
91 Create L<DR::Tnt::Msgpack::Types::Int> object. Its method C<TO_MSGPACK>
92 packs number as msgpack signed integer value.
93  
94 =item mp_string($)
95  
96 Create L<DR::Tnt::Msgpack::Types::Str> object. Its method C<TO_MSGPACK>
97 packs perl scalar as msgpack string.
98  
99 =item mp_blob($)
100  
101 Create L<DR::Tnt::Msgpack::Types::Blob> object. Its method C<TO_MSGPACK>
102 packs perl scalar as msgpack bin object.
103  
104 =item mp_bool($) and shortcuts mp_true/mp_false
105  
106 Create L<DR::Tnt::Msgpack::Types::Bool> object. Its method C<TO_MSGPACK>
107 package perl scalar as msgpack boolean.
108  
109 =back
110  
111 =cut
112 11 1;
« lib/DR/Tnt/LowLevel.pm ↑ Summary