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   281 use 5.010;
  17         53  
2 17     17   101 use strict;
  17         24  
  17         366  
3 17     17   102 use warnings;
  17         32  
  17         437  
4 17     17   93 use utf8;
  17         170  
  17         113  
5              
6             package Neo4j::Driver::SummaryCounters;
7             # ABSTRACT: Statement statistics
8             $Neo4j::Driver::SummaryCounters::VERSION = '0.40';
9              
10             sub new {
11 8     8 0 21 my ($class, $stats) = @_;
12            
13 8         58 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   2237 no strict 'refs'; ##no critic (ProhibitNoStrict)
  17         56  
  17         4147  
30 7     7   510 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       4 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 1575 my $self = shift;
44 3 50       14 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         10 return !! $self->{contains_updates};
49             }
50              
51              
52              
53              
54             1;
55              
56             __END__