ArangoDB2/Graph/Vertex.pm

filter: Statementstmt 22.3% 17 / 76 Branchbran 0.0% 0 / 32 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 35.7% 5 / 14 Podpod 100% 7 / 7 totaltotal 22.4% 29 / 129 CC 20 SCAR 31.7
CC
20
Cov
16%
update
42.0
replace
42.0
get
30.0
CRAP 23.7
« ArangoDB2/Base.pm ↑ Summary ArangoDB2/Cursor.pm »
1 package ArangoDB2::Graph::Vertex;
2  
3 22 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 22 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 22 ▶use base qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
7 ArangoDB2::Base
8 22 );
9  
10 22 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11 22 ▶use JSON::XS;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 22 my $JSON = JSON::XS->new->utf8;
14  
15  
16  
17 # create
18 #
19 # POST /_api/gharial/graph-name/vertex/collection-name
20 sub create
21 0 ▶{
Subroutine create: not called CC=4 SCAR=30.0
Pod documented
22 0 my($self, $data, $args) = @_;
23 # require data
24 0 ▶ die "Invlalid args"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" 0 0 0
25 unless ref $data eq 'HASH';
26 # process args
27 0 $args = $self->_build_args($args, ['waitForSync']);
28 # make request
29 0 ▶ my $res = $self->arango->http->post(
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->post($self->api_path("gharial", $self->graph->name, $self->_class, $self->collection->name), $args, $JSON->encode($data)) or return 0 0 0
30 $self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name),
31 $args,
32 $JSON->encode($data),
33 ) or return;
34 # get response data
35 0 ▶ $res = $res->{$self->_class}
Branch: 1 branch
BranchTrueFalseTotal
$res = $$res{$self->_class} or return 0 0 0
36 or return;
37 # copy response data to instance
38 0 $self->_build_self($res, []);
39 # set data pointer to passed in doc, which will
40 # be updated by future object ops
41 0 $self->{data} = $data;
42 # register object
43 0 my $register = $self->_register;
44 0 $self->collection->$register->{$self->name} = $self;
45  
46 0 return $self;
47 }
48  
49 # delete
50 #
51 # DELETE /system/gharial/graph-name/vertex/collection-name/vertex-key
52 sub delete
53 0 ▶{
Subroutine delete: not called CC=3 SCAR=24.8
Pod documented
54 0 my($self, $args) = @_;
55 # process args
56 0 $args = $self->_build_args($args, ['name', 'waitForSync']);
57 # make request
58 my $res = $self->arango->http->delete(
59 0 ▶ $self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->delete($self->api_path("gharial", $self->graph->name, $self->_class, $self->collection->name, delete $args->{"name"})) or return 0 0 0
60 ) or return;
61 # empty data
62 0 ▶ if (my $data = $self->data) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = $self->data) 0 0 0
63 0 %$data = ();
64 }
65 # unregister object
66 0 my $register = $self->_register;
67 0 delete $self->collection->$register->{$self->name};
68  
69 0 return $res;
70 }
71  
72 # get
73 #
74 # GET /system/gharial/graph-name/vertex/collection-name/vertex-key
75 sub get
76 0 ▶{
Subroutine get: not called CC=5 SCAR=34.0
Pod documented
77 0 my($self, $args) = @_;
78 # process args
79 0 $args = $self->_build_args($args, ['data', 'name']);
80 # make request
81 my $res = $self->arango->http->get(
82 0 ▶ $self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->get($self->api_path("gharial", $self->graph->name, $self->_class, $self->collection->name, delete $args->{"name"})) or return 0 0 0
83 ) or return;
84 # get response data
85 0 ▶ $res = $res->{$self->_class}
Branch: 1 branch
BranchTrueFalseTotal
$res = $$res{$self->_class} or return 0 0 0
86 or return;
87 # copy response data to instance
88 0 $self->_build_self($res, []);
89 # if data is defined already then empty and copy data from response
90 0 ▶ if (my $data = $self->data) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $data = $self->data) { } 0 0 0
91 0 %$data = ();
92 0 $data->{$_} = $res->{$_} for keys %$res;
93 }
94 # otherwise use res for data
95 else {
96 0 $self->data($res);
97 }
98 # register object
99 0 my $register = $self->_register;
100 0 $self->collection->$register->{$self->name} = $self;
101  
102 0 return $self;
103 }
104  
105 # keepNull
106 #
107 # get/set keepNull
108 0 ▶sub keepNull { shift->_get_set_bool('keepNull', @_) }
Subroutine keepNull: not called CC=1 SCAR=6.9
Pod documented
109  
110 # update
111 #
112 # PATCH /system/gharial/graph-name/vertex/collection-name/vertex-key
113 sub update
114 0 ▶{
Subroutine update: not called CC=6 SCAR=37.4
Pod documented
115 0 my($self, $data, $args) = @_;
116 # require data
117 0 ▶ die "Invalid args"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" 0 0 0
118 unless ref $data eq 'HASH';
119 # process args
120 0 $args = $self->_build_args($args, ['name', 'keepNull', 'waitForSync']);
121 # make request
122 my $res = $self->arango->http->patch(
123 0 ▶ $self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->patch($self->api_path("gharial", $self->graph->name, $self->_class, $self->collection->name, delete $args->{"name"}), $args, $JSON->encode($data)) or return 0 0 0
124 $args,
125 $JSON->encode($data),
126 ) or return;
127 # get response data
128 0 ▶ $res = $res->{$self->_class}
Branch: 1 branch
BranchTrueFalseTotal
$res = $$res{$self->_class} or return 0 0 0
129 or return;
130 # copy response data to instance
131 0 $self->_build_self($res, []);
132 # if data is defined then copy patched data
133 0 ▶ if (my $orig_data = $self->data) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $orig_data = $self->data) { } 0 0 0
134 0 $orig_data->{$_} = $data->{$_} for keys %$data;
135 }
136 # otherwise use passed data
137 else {
138 0 $self->data($data);
139 }
140 # register object
141 0 my $register = $self->_register;
142 0 $self->collection->$register->{$self->name} = $self;
143  
144 0 return $self;
145 }
146  
147 # replace
148 #
149 # PUT /system/gharial/graph-name/vertex/collection-name/vertex-key
150 sub replace
151 0 ▶{
Subroutine replace: not called CC=6 SCAR=37.4
Pod documented
152 0 my($self, $data, $args) = @_;
153 # require data
154 0 ▶ die "Invlalid args"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $data eq "HASH" 0 0 0
155 unless ref $data eq 'HASH';
156 # process args
157 0 $args = $self->_build_args($args, ['name', 'waitForSync']);
158 # make request
159 my $res = $self->arango->http->put(
160 0 ▶ $self->api_path('gharial', $self->graph->name, $self->_class, $self->collection->name, delete $args->{name}),
Branch: 1 branch
BranchTrueFalseTotal
my $res = $self->arango->http->put($self->api_path("gharial", $self->graph->name, $self->_class, $self->collection->name, delete $args->{"name"}), $args, $JSON->encode($data)) or return 0 0 0
161 $args,
162 $JSON->encode($data),
163 ) or return;
164 # get response data
165 0 ▶ $res = $res->{$self->_class}
Branch: 1 branch
BranchTrueFalseTotal
$res = $$res{$self->_class} or return 0 0 0
166 or return;
167 # copy response data to instance
168 0 $self->_build_self($res, []);
169 # if data is defined then replace data
170 0 ▶ if (my $orig_data = $self->data) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $orig_data = $self->data) { } 0 0 0
171 0 %$orig_data = ();
172 0 $orig_data->{$_} = $data->{$_} for keys %$data;
173 }
174 # otherwise use passed data
175 else {
176 0 $self->data($data);
177 }
178 # register object
179 0 my $register = $self->_register;
180 0 $self->collection->$register->{$self->name} = $self;
181  
182 0 return $self;
183 }
184  
185 # waitForSync
186 #
187 # get/set waitForSync
188 0 ▶sub waitForSync { shift->_get_set_bool('waitForSync', @_) }
Subroutine waitForSync: not called CC=1 SCAR=6.9
Pod documented
189  
190 # _class
191 #
192 # internal name for class
193 0 ▶sub _class { 'vertex' }
Subroutine _class: not called CC=1 SCAR=6.9
194  
195 # _register
196 #
197 # internal name for object index
198 0 ▶sub _register { 'vertices' }
Subroutine _register: not called CC=1 SCAR=6.9
199  
200 22 1;
201  
202 __END__
« ArangoDB2/Base.pm ↑ Summary ArangoDB2/Cursor.pm »