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 60     60   73498 use strict;
  60         151  
  60         1827  
16 60     60   314 use warnings;
  60         144  
  60         2046  
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 60     60   326 use version;
  60         137  
  60         315  
23             our $VERSION = 'v2.2.1';
24              
25 60     60   4519 use Moo::Role;
  60         151  
  60         392  
26              
27 60         483 use MongoDB::_Types qw(
28             Boolish
29             BSONCodec
30             ClientSession
31             Stringish
32 60     60   20814 );
  60         163  
33 60         405 use Types::Standard qw(
34             CodeRef
35             Maybe
36 60     60   93310 );
  60         137  
37              
38 60     60   49218 use namespace::clean;
  60         140  
  60         451  
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;