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 59     59   311649 use strict;
  59         166  
  59         1832  
16 59     59   321 use warnings;
  59         153  
  59         2291  
17              
18             package MongoDB::Role::_BypassValidation;
19              
20             # MongoDB interface for optionally applying bypassDocumentValidation
21             # to a command
22              
23 59     59   331 use version;
  59         145  
  59         379  
24             our $VERSION = 'v2.2.1';
25              
26 59     59   4573 use Moo::Role;
  59         142  
  59         514  
27              
28 59         624 use MongoDB::_Types qw(
29             Boolish
30 59     59   21689 );
  59         201  
31 59     59   66972 use boolean;
  59         150  
  59         546  
32              
33 59     59   4401 use namespace::clean;
  59         152  
  59         407  
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;