File Coverage

lib/Neo4j/Driver/SummaryCounters.pm
Criterion Covered Total %
statement 17 20 85.0
branch 2 4 50.0
condition 0 2 0.0
subroutine 7 7 100.0
pod 0 3 0.0
total 26 36 72.2


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