File Coverage

lib/Neo4j/Driver/SummaryCounters.pm
Criterion Covered Total %
statement 23 26 88.4
branch 2 4 50.0
condition 0 2 0.0
subroutine 9 9 100.0
pod 0 3 0.0
total 34 44 77.2


line stmt bran cond sub pod time code
1 17     17   278 use 5.010;
  17         51  
2 17     17   138 use strict;
  17         35  
  17         401  
3 17     17   89 use warnings;
  17         41  
  17         455  
4 17     17   96 use utf8;
  17         148  
  17         121  
5              
6             package Neo4j::Driver::SummaryCounters;
7             # ABSTRACT: Statement statistics
8             $Neo4j::Driver::SummaryCounters::VERSION = '0.38';
9              
10             sub new {
11 8     8 0 18 my ($class, $stats) = @_;
12            
13 8         42 return bless $stats, $class;
14             }
15              
16              
17             my @counters = qw(
18             constraints_added
19             constraints_removed
20             indexes_added
21             indexes_removed
22             labels_added
23             labels_removed
24             nodes_created
25             nodes_deleted
26             properties_set
27             relationships_created
28             );
29 17     17   2145 no strict 'refs'; ##no critic (ProhibitNoStrict)
  17         57  
  17         4058  
30 7     7   454 for my $c (@counters) { *$c = sub { shift->{$c} } }
31              
32             # This name is a typo that drivers are supposed to fix;
33             # see
34             sub relationships_deleted {
35 1     1 0 3 my $self = shift;
36 1 50       6 return $self->{relationships_deleted} if defined $self->{relationships_deleted};
37 1         4 return $self->{relationship_deleted};
38             }
39              
40             # contains_updates is only present in the HTTP response;
41             # we need to synthesize it from Bolt responses
42             sub contains_updates {
43 3     3 0 1629 my $self = shift;
44 3 50       12 unless (defined $self->{contains_updates}) {
45 0   0     0 $self->{contains_updates} = $self->{relationships_deleted} // 0;
46 0         0 $self->{contains_updates} += grep {$self->{$_}} @counters;
  0         0  
47             }
48 3         13 return !! $self->{contains_updates};
49             }
50              
51              
52              
53              
54             1;
55              
56             __END__