| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | #  Copyright 2016 - 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 |  | 442 | use strict; | 
|  | 59 |  |  |  |  | 140 |  | 
|  | 59 |  |  |  |  | 1853 |  | 
| 16 | 59 |  |  | 59 |  | 335 | use warnings; | 
|  | 59 |  |  |  |  | 135 |  | 
|  | 59 |  |  |  |  | 2245 |  | 
| 17 |  |  |  |  |  |  | package MongoDB::Op::_DropCollection; | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | # Implements a collection drop; returns a MongoDB::CommandResult | 
| 20 |  |  |  |  |  |  |  | 
| 21 | 59 |  |  | 59 |  | 336 | use version; | 
|  | 59 |  |  |  |  | 133 |  | 
|  | 59 |  |  |  |  | 378 |  | 
| 22 |  |  |  |  |  |  | our $VERSION = 'v2.2.1'; | 
| 23 |  |  |  |  |  |  |  | 
| 24 | 59 |  |  | 59 |  | 4455 | use Moo; | 
|  | 59 |  |  |  |  | 153 |  | 
|  | 59 |  |  |  |  | 334 |  | 
| 25 |  |  |  |  |  |  |  | 
| 26 | 59 |  |  | 59 |  | 18624 | use MongoDB::Error; | 
|  | 59 |  |  |  |  | 184 |  | 
|  | 59 |  |  |  |  | 7294 |  | 
| 27 | 59 |  |  | 59 |  | 440 | use MongoDB::Op::_Command; | 
|  | 59 |  |  |  |  | 206 |  | 
|  | 59 |  |  |  |  | 1486 |  | 
| 28 | 59 |  |  | 59 |  | 358 | use Safe::Isa; | 
|  | 59 |  |  |  |  | 165 |  | 
|  | 59 |  |  |  |  | 7755 |  | 
| 29 | 59 |  |  | 59 |  | 551 | use namespace::clean; | 
|  | 59 |  |  |  |  | 143 |  | 
|  | 59 |  |  |  |  | 453 |  | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | with $_ for qw( | 
| 32 |  |  |  |  |  |  | MongoDB::Role::_PrivateConstructor | 
| 33 |  |  |  |  |  |  | MongoDB::Role::_CollectionOp | 
| 34 |  |  |  |  |  |  | MongoDB::Role::_WriteOp | 
| 35 |  |  |  |  |  |  | ); | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub execute { | 
| 38 | 0 |  |  | 0 | 0 |  | my ( $self, $link ) = @_; | 
| 39 |  |  |  |  |  |  |  | 
| 40 |  |  |  |  |  |  | my $op = MongoDB::Op::_Command->_new( | 
| 41 |  |  |  |  |  |  | db_name => $self->db_name, | 
| 42 |  |  |  |  |  |  | query   => [ | 
| 43 |  |  |  |  |  |  | drop => $self->coll_name, | 
| 44 | 0 | 0 |  |  |  |  | ( $link->supports_helper_write_concern ? ( @{ $self->write_concern->as_args } ) : () ), | 
|  | 0 |  |  |  |  |  |  | 
| 45 |  |  |  |  |  |  | ], | 
| 46 |  |  |  |  |  |  | query_flags         => {}, | 
| 47 |  |  |  |  |  |  | bson_codec          => $self->bson_codec, | 
| 48 |  |  |  |  |  |  | session             => $self->session, | 
| 49 |  |  |  |  |  |  | monitoring_callback => $self->monitoring_callback, | 
| 50 |  |  |  |  |  |  | ); | 
| 51 |  |  |  |  |  |  |  | 
| 52 | 0 |  |  |  |  |  | my $res; | 
| 53 |  |  |  |  |  |  | eval { | 
| 54 | 0 |  |  |  |  |  | $res = $op->execute($link); | 
| 55 | 0 |  |  |  |  |  | $res->assert_no_write_concern_error; | 
| 56 | 0 |  |  |  |  |  | 1; | 
| 57 | 0 | 0 |  |  |  |  | } or do { | 
| 58 | 0 |  | 0 |  |  |  | my $error = $@ || "Unknown error"; | 
| 59 | 0 | 0 |  |  |  |  | if ( $error->$_isa("MongoDB::DatabaseError") ) { | 
| 60 | 0 | 0 | 0 |  |  |  | return undef if $error->code == NAMESPACE_NOT_FOUND() || $error->message =~ /^ns not found/; ## no critic: make $res undef | 
| 61 |  |  |  |  |  |  | } | 
| 62 | 0 |  |  |  |  |  | die $error; | 
| 63 |  |  |  |  |  |  | }; | 
| 64 |  |  |  |  |  |  |  | 
| 65 | 0 |  |  |  |  |  | return $res; | 
| 66 |  |  |  |  |  |  | } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  | 1; |