File Coverage

blib/lib/MongoDB/Role/_BypassValidation.pm
Criterion Covered Total %
statement 21 24 87.5
branch 0 2 0.0
condition 0 3 0.0
subroutine 7 8 87.5
pod n/a
total 28 37 75.6


line stmt bran cond sub pod time code
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 58     58   304589 use strict;
  58         169  
  58         1895  
16 58     58   337 use warnings;
  58         146  
  58         2323  
17              
18             package MongoDB::Role::_BypassValidation;
19              
20             # MongoDB interface for optionally applying bypassDocumentValidation
21             # to a command
22              
23 58     58   324 use version;
  58         144  
  58         368  
24             our $VERSION = 'v2.2.0';
25              
26 58     58   4591 use Moo::Role;
  58         175  
  58         483  
27              
28 58         641 use MongoDB::_Types qw(
29             Boolish
30 58     58   21476 );
  58         212  
31 58     58   66466 use boolean;
  58         147  
  58         574  
32              
33 58     58   4405 use namespace::clean;
  58         156  
  58         443  
34              
35             has bypassDocumentValidation => (
36             is => 'ro',
37             isa => Boolish,
38             );
39              
40             # args not unpacked for efficiency; args are self, validation supported
41             # flag, original command; returns (possibly modified) command
42             sub _maybe_bypass {
43 0 0 0 0     push @{ $_[2] },
  0            
44             bypassDocumentValidation => true if $_[1] && $_[0]->bypassDocumentValidation;
45 0           return $_[2];
46             }
47              
48             1;