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   386 use 5.010;
  17         58  
2 17     17   103 use strict;
  17         31  
  17         398  
3 17     17   89 use warnings;
  17         28  
  17         423  
4 17     17   86 use utf8;
  17         139  
  17         112  
5              
6             package Neo4j::Driver::SummaryCounters;
7             # ABSTRACT: Statement statistics
8             $Neo4j::Driver::SummaryCounters::VERSION = '0.39';
9              
10             sub new {
11 8     8 0 21 my ($class, $stats) = @_;
12            
13 8         46 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   2115 no strict 'refs'; ##no critic (ProhibitNoStrict)
  17         52  
  17         4244  
30 7     7   465 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       5 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 1589 my $self = shift;
44 3 50       17 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         12 return !! $self->{contains_updates};
49             }
50              
51              
52              
53              
54             1;
55              
56             __END__