File Coverage

blib/lib/MongoDB/Role/_DatabaseOp.pm
Criterion Covered Total %
statement 21 21 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod n/a
total 28 28 100.0


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   69693 use strict;
  59         153  
  59         1863  
16 59     59   312 use warnings;
  59         127  
  59         1996  
17             package MongoDB::Role::_DatabaseOp;
18              
19             # MongoDB role for operations within a database, that need a database name
20             # and a BSON codec. This is likely a "base role" for all operations.
21              
22 59     59   318 use version;
  59         122  
  59         327  
23             our $VERSION = 'v2.2.0';
24              
25 59     59   4409 use Moo::Role;
  59         155  
  59         379  
26              
27 59         573 use MongoDB::_Types qw(
28             Boolish
29             BSONCodec
30             ClientSession
31             Stringish
32 59     59   19777 );
  59         139  
33 59         437 use Types::Standard qw(
34             CodeRef
35             Maybe
36 59     59   90812 );
  59         177  
37              
38 59     59   46837 use namespace::clean;
  59         142  
  59         476  
39              
40             has bson_codec => (
41             is => 'ro',
42             required => 1,
43             isa => BSONCodec,
44             );
45              
46             has db_name => (
47             is => 'ro',
48             required => 1,
49             isa => Stringish,
50             );
51              
52             # required, but allowed to be undef so we're sure this gets wired up
53             # correctly through all database ops.
54             has monitoring_callback => (
55             is => 'ro',
56             required => 1,
57             isa => Maybe[CodeRef],
58             );
59              
60             has session => (
61             is => 'ro',
62             required => 0,
63             isa => Maybe[ClientSession],
64             );
65              
66             # set during retryable writes on supported operations
67             has retryable_write => (
68             is => 'rw',
69             isa => Boolish,
70             default => 0,
71             );
72              
73             # set during retryable reads on supported operations
74             has retryable_read => (
75             is => 'rw',
76             isa => Boolish,
77             default => 0,
78             );
79              
80             1;