MongoDB/OID.pm untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 49 CC 1 SCAR 6.9
CC
1
Cov
0%
BUILD
2.0
_new_oid
2.0
BEGIN
2.0
CRAP 2.0
1 # Copyright 2009 - 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 use strict;
16 use warnings;
17 package MongoDB::OID;
18  
19 # ABSTRACT: (DEPRECATED) A Mongo Object ID
20  
21 use version;
22 our $VERSION = 'v2.2.2';
23  
24  
25 use Moo;
26 extends 'BSON::OID';
27 use namespace::clean -except => 'meta';
28  
29 with $_ for qw(
30 MongoDB::Role::_DeprecationWarner
31 );
32  
33 sub BUILD {
34 my $self = shift;
35 $self->_warn_deprecated_class(__PACKAGE__, ["BSON::OID"], 0);
36 };
37  
38 around BUILDARGS => sub {
39 my $orig = shift;
40 my $class = shift;
41 if ( @_ == 0 ) {
42 return {};
43 }
44 if ( @_ == 1 ) {
45 return { oid => pack("H*",$_[0]) };
46 }
47 # convert 'value' to 'oid'
48 my %args = @_;
49 if ( $args{value} ) {
50 $args{oid} = pack("H*", delete $args{value});
51 }
52 return $orig->($class, %args);
53 };
54  
55 # This private constructor bypasses everything Moo does for us and just
56 # jams an OID into a blessed hashref. This is only for use in super-hot
57 # code paths, like document insertion.
58 sub _new_oid {
59 return bless { oid => BSON::OID::_generate_oid() }, "BSON::OID";
60 }
61  
62 1;
63  
64 __END__