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   400 use strict;
  59         132  
  59         1770  
16 59     59   308 use warnings;
  59         133  
  59         1900  
17             package MongoDB::InsertManyResult;
18              
19             # ABSTRACT: MongoDB single insert result object
20              
21 59     59   312 use version;
  59         138  
  59         347  
22             our $VERSION = 'v2.2.1';
23              
24 59     59   4574 use Moo;
  59         202  
  59         348  
25 59     59   18486 use MongoDB::_Constants;
  59         170  
  59         7807  
26 59         490 use MongoDB::_Types qw(
27             ArrayOfHashRef
28             Numish
29 59     59   478 );
  59         151  
30 59         389 use Types::Standard qw(
31             HashRef
32 59     59   69708 );
  59         165  
33 59     59   40605 use namespace::clean;
  59         153  
  59         482  
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__