File Coverage

blib/lib/MongoDB/InsertManyResult.pm
Criterion Covered Total %
statement 24 31 77.4
branch n/a
condition n/a
subroutine 8 10 80.0
pod n/a
total 32 41 78.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   353 use strict;
  59         110  
  59         1432  
16 59     59   259 use warnings;
  59         134  
  59         1686  
17             package MongoDB::InsertManyResult;
18              
19             # ABSTRACT: MongoDB single insert result object
20              
21 59     59   285 use version;
  59         139  
  59         309  
22             our $VERSION = 'v2.2.2';
23              
24 59     59   4059 use Moo;
  59         154  
  59         348  
25 59     59   15750 use MongoDB::_Constants;
  59         142  
  59         7148  
26 59         482 use MongoDB::_Types qw(
27             ArrayOfHashRef
28             Numish
29 59     59   424 );
  59         125  
30 59         397 use Types::Standard qw(
31             HashRef
32 59     59   62132 );
  59         116  
33 59     59   35263 use namespace::clean;
  59         120  
  59         448  
34              
35             with $_ for qw(
36             MongoDB::Role::_PrivateConstructor
37             MongoDB::Role::_WriteResult
38             );
39              
40             #pod =attr inserted_count
41             #pod
42             #pod The number of documents inserted.
43             #pod
44             #pod =cut
45              
46             has inserted_count => (
47             is => 'lazy',
48             builder => '_build_inserted_count',
49             isa => Numish,
50             );
51              
52             sub _build_inserted_count
53             {
54 0     0     my ($self) = @_;
55 0           return scalar @{ $self->inserted };
  0            
56             }
57              
58             #pod =attr inserted
59             #pod
60             #pod An array reference containing information about inserted documents (if any).
61             #pod Documents are just as in C.
62             #pod
63             #pod =cut
64              
65             has inserted => (
66             is => 'ro',
67             default => sub { [] },
68             isa => ArrayOfHashRef,
69             );
70              
71             #pod =attr inserted_ids
72             #pod
73             #pod A hash reference built lazily from C mapping indexes to object
74             #pod IDs.
75             #pod
76             #pod =cut
77              
78             has inserted_ids => (
79             is => 'lazy',
80             builder => '_build_inserted_ids',
81             isa => HashRef,
82             );
83              
84             sub _build_inserted_ids {
85 0     0     my ($self) = @_;
86 0           return { map { $_->{index}, $_->{_id} } @{ $self->inserted } };
  0            
  0            
87             }
88              
89             1;
90              
91             __END__