| 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 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 16 | 59 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | package MongoDB::InsertManyResult; | ||
| 18 | |||
| 19 | # ABSTRACT: MongoDB single insert result object | ||
| 20 | |||
| 21 | 59 | ▶ | use version; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 22 | 59 | our $VERSION = 'v2.2.2'; | |
| 23 | |||
| 24 | 59 | ▶ | use Moo; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 25 | 59 | ▶ | use MongoDB::_Constants; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 26 | 59 | ▶ | use MongoDB::_Types qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 27 | ArrayOfHashRef | ||
| 28 | Numish | ||
| 29 | 59 | ); | |
| 30 | 59 | ▶ | use Types::Standard qw( |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 31 | HashRef | ||
| 32 | 59 | ); | |
| 33 | 59 | ▶ | use namespace::clean; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 34 | |||
| 35 | 59 | 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 | 59 | has inserted_count => ( | |
| 47 | is => 'lazy', | ||
| 48 | builder => '_build_inserted_count', | ||
| 49 | isa => Numish, | ||
| 50 | ); | ||
| 51 | |||
| 52 | sub _build_inserted_count | ||
| 53 | 0 | ▶ | { |
|
Subroutine
_build_inserted_count: not called CC=1 SCAR=6.9
| |||
| 54 | 0 | my ($self) = @_; | |
| 55 | 0 | return scalar @{ $self->inserted }; | |
| 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<upserted>. | ||
| 62 | #pod | ||
| 63 | #pod =cut | ||
| 64 | |||
| 65 | has inserted => ( | ||
| 66 | is => 'ro', | ||
| 67 | 0 | ▶ | default => sub { [] }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 68 | 59 | isa => ArrayOfHashRef, | |
| 69 | ); | ||
| 70 | |||
| 71 | #pod =attr inserted_ids | ||
| 72 | #pod | ||
| 73 | #pod A hash reference built lazily from C<inserted> mapping indexes to object | ||
| 74 | #pod IDs. | ||
| 75 | #pod | ||
| 76 | #pod =cut | ||
| 77 | |||
| 78 | 59 | has inserted_ids => ( | |
| 79 | is => 'lazy', | ||
| 80 | builder => '_build_inserted_ids', | ||
| 81 | isa => HashRef, | ||
| 82 | ); | ||
| 83 | |||
| 84 | 0 | ▶ | sub _build_inserted_ids { |
|
Subroutine
_build_inserted_ids: not called CC=1 SCAR=6.9
| |||
| 85 | 0 | my ($self) = @_; | |
| 86 | 0 | return { map { $_->{index}, $_->{_id} } @{ $self->inserted } }; | |
| 87 | } | ||
| 88 | |||
| 89 | 59 | 1; | |
| 90 | |||
| 91 | __END__ | ||