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   176766 use strict;
  59         130  
  59         1599  
16 59     59   273 use warnings;
  59         105  
  59         1986  
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   272 use version;
  59         110  
  59         330  
23             our $VERSION = 'v2.2.2';
24              
25 59     59   4096 use Moo::Role;
  59         128  
  59         399  
26              
27 59         534 use MongoDB::_Types qw(
28             WriteConcern
29 59     59   19428 );
  59         135  
30              
31 59     59   59914 use namespace::clean;
  59         146  
  59         379  
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;