File Coverage

blib/lib/MongoDB/Role/_WriteOp.pm
Criterion Covered Total %
statement 18 21 85.7
branch 0 2 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod n/a
total 24 33 72.7


line stmt bran cond sub pod time code
1             # Copyright 2014 - 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     59   191289 use strict;
  59         152  
  59         1793  
16 59     59   337 use warnings;
  59         129  
  59         2129  
17             package MongoDB::Role::_WriteOp;
18              
19             # MongoDB interface for database write operations (whether write commands
20             # or other things that take a write concern)
21              
22 59     59   323 use version;
  59         124  
  59         310  
23             our $VERSION = 'v2.2.1';
24              
25 59     59   4423 use Moo::Role;
  59         136  
  59         555  
26              
27 59         521 use MongoDB::_Types qw(
28             WriteConcern
29 59     59   22584 );
  59         170  
30              
31 59     59   65734 use namespace::clean;
  59         140  
  59         371  
32              
33             has write_concern => (
34             is => 'ro',
35             required => 1,
36             isa => WriteConcern,
37             );
38              
39             sub _should_use_acknowledged_write {
40 0     0     my $self = shift;
41              
42             # We should never use an unacknowledged write concern in an active transaction
43 0 0 0       return 1 if $self->session && $self->session->_active_transaction;
44 0           return $self->write_concern->is_acknowledged;
45             }
46              
47             1;