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 58     58   434 use strict;
  58         136  
  58         1606  
16 58     58   294 use warnings;
  58         131  
  58         1825  
17             package MongoDB::InsertManyResult;
18              
19             # ABSTRACT: MongoDB single insert result object
20              
21 58     58   331 use version;
  58         140  
  58         307  
22             our $VERSION = 'v2.2.0';
23              
24 58     58   4414 use Moo;
  58         176  
  58         369  
25 58     58   18665 use MongoDB::_Constants;
  58         170  
  58         8261  
26 58         887 use MongoDB::_Types qw(
27             ArrayOfHashRef
28             Numish
29 58     58   449 );
  58         149  
30 58         398 use Types::Standard qw(
31             HashRef
32 58     58   69206 );
  58         149  
33 58     58   39729 use namespace::clean;
  58         142  
  58         444  
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__