MongoDB/ReadConcern.pm

filter: Statementstmt 100% 31 / 31 Branchbran 75.0% 6 / 8 Conditioncond 33.3% 2 / 6 MC/DCmcdc 0.0% 0 / 4 Subroutinesub 100% 9 / 9 Podpod 0.0% 0 / 2 totaltotal 80.0% 48 / 60 CC 7 SCAR 13.6
CC
7
Cov
87%
as_args
7.9
BUILD
2.0
BEGIN
1.0
CRAP 3.9
« MongoDB/Role/_BypassValidation.pm ↑ Summary MongoDB/Op/_InsertOne.pm »
1 # Copyright 2015 - present MongoDB, Inc.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14  
15 59 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 59 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 package MongoDB::ReadConcern;
18  
19 # ABSTRACT: Encapsulate and validate a read concern
20  
21 59 ▶use version;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 59 our $VERSION = 'v2.2.2';
23  
24 59 ▶use Moo;
Subroutine BEGIN: called CC=1 SCAR=0.0
25 59 ▶use MongoDB::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
26 59 ▶use Types::Standard qw(
Subroutine BEGIN: called CC=1 SCAR=0.0
27 Maybe
28 Str
29 ArrayRef
30 59 );
31  
32 59 ▶use namespace::clean;
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 #pod =attr level
35 #pod
36 #pod The read concern level determines the consistency level required
37 #pod of data being read.
38 #pod
39 #pod The default level is C<undef>, which means the server will use its configured
40 #pod default.
41 #pod
42 #pod If the level is set to "local", reads will return the latest data a server has
43 #pod locally.
44 #pod
45 #pod Additional levels are storage engine specific. See L<Read
46 #pod Concern|http://docs.mongodb.org/manual/search/?query=readConcern> in the MongoDB
47 #pod documentation for more details.
48 #pod
49 #pod This may be set in a connection string with the the C<readConcernLevel> option.
50 #pod
51 #pod =cut
52  
53 59 has level => (
54 is => 'ro',
55 isa => Maybe [Str],
56 predicate => 'has_level',
57 );
58  
59 11 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
60 11 my $self = shift;
61 11 ▶ if ( defined $self->{level} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"level"}) 9 2 11
62 9 $self->{level} = lc $self->{level};
63 }
64 }
65  
66 # public interface for compatibility, but undocumented
67 6 ▶sub as_args {
Subroutine as_args: called CC=6 SCAR=20.7
Pod undocumented
68 6 my ( $self, $session ) = @_;
69  
70 # if session is defined and operation_time is not, then either the
71 # operation_time was not sent on the response from the server for this
72 # session or the session has causal consistency disabled.
73 6 ▶ if ( $self->{level} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'level'}) { } 5 1 6
74 return [
75 readConcern => {
76 level => $self->{level},
77 5 ▶ ( defined $session && defined $session->operation_time
Branch: 1 branch
BranchTrueFalseTotal
defined $session && defined $session->operation_time ? : 0 5 5
Condition33%1/3
defined $session and defined $session->operation_time
!ll&&!rl&&r
500
MC/DC0%0/2
defined $session and defined $session->operation_time
defined $session defined $session->operation_time
Truth table33%1/3
A and B
A= defined $sessionB= defined $session->operation_time
ABresult
0X0
100
111
78 ? ( afterClusterTime => $session->operation_time )
79 : () ),
80 }
81 ];
82 }
83 else {
84 return [
85 1 ▶ ( defined $session && defined $session->operation_time
Branch: 1 branch
BranchTrueFalseTotal
defined $session && defined $session->operation_time ? : 0 1 1
Condition33%1/3
defined $session and defined $session->operation_time
!ll&&!rl&&r
100
MC/DC0%0/2
defined $session and defined $session->operation_time
defined $session defined $session->operation_time
Truth table33%1/3
A and B
A= defined $sessionB= defined $session->operation_time
ABresult
0X0
100
111
86 ? ( readConcern => { afterClusterTime => $session->operation_time } )
87 : ()
88 )
89 ];
90 }
91 }
92  
93 59 1;
94  
95 __END__
« MongoDB/Role/_BypassValidation.pm ↑ Summary MongoDB/Op/_InsertOne.pm »