| 1 | 71 | ▶ | use 5.010001; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 2 | 71 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 3 | 71 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | |||||||||||
| 5 | package BSON::DBPointer; | ||||||||||
| 6 | # ABSTRACT: Legacy BSON type wrapper for DBPointer data (DEPRECATED) | ||||||||||
| 7 | |||||||||||
| 8 | 71 | our $VERSION = 'v1.12.2'; | |||||||||
| 9 | |||||||||||
| 10 | 71 | ▶ | use Moo 2.002004; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 71 | ▶ | use Tie::IxHash; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 71 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 71 | extends 'BSON::DBRef'; | |||||||||
| 16 | |||||||||||
| 17 | 4 | ▶ | sub TO_JSON { | ||||||||
|
Subroutine
TO_JSON: called CC=5 SCAR=16.7
Pod
documented
| |||||||||||
| 18 | 4 | my $self = shift; | |||||||||
| 19 | |||||||||||
| 20 | 4 | ▶ | if ( $ENV{BSON_EXTJSON} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 21 | |||||||||||
| 22 | 4 | my $id = $self->id; | |||||||||
| 23 | 4 | ▶ | if (ref $id) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 4 | $id = $id->TO_JSON; | |||||||||
| 25 | } | ||||||||||
| 26 | else { | ||||||||||
| 27 | 0 | $id = BSON->perl_to_extjson($id); | |||||||||
| 28 | } | ||||||||||
| 29 | |||||||||||
| 30 | 4 | my %data; | |||||||||
| 31 | 4 | tie( %data, 'Tie::IxHash' ); | |||||||||
| 32 | 4 | $data{'$ref'} = $self->ref; | |||||||||
| 33 | 4 | $data{'$id'} = $id; | |||||||||
| 34 | 4 | ▶ | $data{'$db'} = $self->db | ||||||||
|
Branch: 1 branch
| |||||||||||
| 35 | if defined $self->db; | ||||||||||
| 36 | |||||||||||
| 37 | 4 | my $extra = $self->extra; | |||||||||
| 38 | $data{$_} = $extra->{$_} | ||||||||||
| 39 | 4 | for keys %$extra; | |||||||||
| 40 | |||||||||||
| 41 | 4 | return \%data; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 0 | Carp::croak( "The value '$self' is illegal in JSON" ); | |||||||||
| 45 | } | ||||||||||
| 46 | |||||||||||
| 47 | 71 | 1; | |||||||||
| 48 | |||||||||||
| 49 | =pod | ||||||||||
| 50 | |||||||||||
| 51 | =encoding UTF-8 | ||||||||||
| 52 | |||||||||||
| 53 | =head1 NAME | ||||||||||
| 54 | |||||||||||
| 55 | BSON::DBPointer - Legacy BSON type wrapper for DBPointer data (DEPRECATED) | ||||||||||
| 56 | |||||||||||
| 57 | =head1 VERSION | ||||||||||
| 58 | |||||||||||
| 59 | version v1.12.2 | ||||||||||
| 60 | |||||||||||
| 61 | =head1 DESCRIPTION | ||||||||||
| 62 | |||||||||||
| 63 | This module wraps the deprecated BSON "DBPointer" type. | ||||||||||
| 64 | |||||||||||
| 65 | You are strongly encouraged to use L<BSON::DBRef> instead. | ||||||||||
| 66 | |||||||||||
| 67 | =head1 AUTHORS | ||||||||||
| 68 | |||||||||||
| 69 | =over 4 | ||||||||||
| 70 | |||||||||||
| 71 | =item * | ||||||||||
| 72 | |||||||||||
| 73 | David Golden <david@mongodb.com> | ||||||||||
| 74 | |||||||||||
| 75 | =item * | ||||||||||
| 76 | |||||||||||
| 77 | Stefan G. <minimalist@lavabit.com> | ||||||||||
| 78 | |||||||||||
| 79 | =back | ||||||||||
| 80 | |||||||||||
| 81 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 82 | |||||||||||
| 83 | This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc. | ||||||||||
| 84 | |||||||||||
| 85 | This is free software, licensed under: | ||||||||||
| 86 | |||||||||||
| 87 | The Apache License, Version 2.0, January 2004 | ||||||||||
| 88 | |||||||||||
| 89 | =cut | ||||||||||
| 90 | |||||||||||
| 91 | __END__ | ||||||||||