| 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::Raw; | ||||||||||
| 6 | # ABSTRACT: BSON type wrapper for pre-encoded BSON documents | ||||||||||
| 7 | |||||||||||
| 8 | 71 | ▶ | use version; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 71 | our $VERSION = 'v1.12.2'; | |||||||||
| 10 | |||||||||||
| 11 | 71 | ▶ | use Moo; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | |||||||||||
| 13 | #pod =attr bson | ||||||||||
| 14 | #pod | ||||||||||
| 15 | #pod A string containing a BSON-encoded document. Default is C<undef>. | ||||||||||
| 16 | #pod | ||||||||||
| 17 | #pod =attr metadata | ||||||||||
| 18 | #pod | ||||||||||
| 19 | #pod A hash reference containing arbitrary metadata about the BSON document. | ||||||||||
| 20 | #pod Default is C<undef>. | ||||||||||
| 21 | #pod | ||||||||||
| 22 | #pod =cut | ||||||||||
| 23 | |||||||||||
| 24 | 71 | has [qw/bson metadata/] => ( | |||||||||
| 25 | is => 'ro' | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | 71 | ▶ | use namespace::clean -except => 'meta'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 29 | |||||||||||
| 30 | # Returns the first key of an encoded hash passed via BSON::Raw->new(bson=>$bson). | ||||||||||
| 31 | # If the BSON document has no key, it will return C<undef>. | ||||||||||
| 32 | 1 | ▶ | sub _get_first_key { | ||||||||
|
Subroutine
_get_first_key: called CC=2 SCAR=7.0
| |||||||||||
| 33 | 1 | my ($self) = @_; | |||||||||
| 34 | |||||||||||
| 35 | 1 | ▶ | return undef if length( $self->bson ) <= 5; ## no critic | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | |||||||||||
| 37 | 1 | my ( undef, undef, $key ) = unpack( "lCZ*", $self->bson ); | |||||||||
| 38 | 1 | return $key; | |||||||||
| 39 | } | ||||||||||
| 40 | |||||||||||
| 41 | 71 | 1; | |||||||||
| 42 | |||||||||||
| 43 | =pod | ||||||||||
| 44 | |||||||||||
| 45 | =encoding UTF-8 | ||||||||||
| 46 | |||||||||||
| 47 | =head1 NAME | ||||||||||
| 48 | |||||||||||
| 49 | BSON::Raw - BSON type wrapper for pre-encoded BSON documents | ||||||||||
| 50 | |||||||||||
| 51 | =head1 VERSION | ||||||||||
| 52 | |||||||||||
| 53 | version v1.12.2 | ||||||||||
| 54 | |||||||||||
| 55 | =head1 SYNOPSIS | ||||||||||
| 56 | |||||||||||
| 57 | use BSON::Types ':all'; | ||||||||||
| 58 | |||||||||||
| 59 | my $ordered = bson_raw( $bson_bytes ); | ||||||||||
| 60 | |||||||||||
| 61 | =head1 DESCRIPTION | ||||||||||
| 62 | |||||||||||
| 63 | This module provides a BSON document wrapper for already-encoded BSON bytes. | ||||||||||
| 64 | |||||||||||
| 65 | Generally, end-users should have no need for this; it is provided for | ||||||||||
| 66 | optimization purposes for L<MongoDB> or other client libraries. | ||||||||||
| 67 | |||||||||||
| 68 | =head1 ATTRIBUTES | ||||||||||
| 69 | |||||||||||
| 70 | =head2 bson | ||||||||||
| 71 | |||||||||||
| 72 | A string containing a BSON-encoded document. Default is C<undef>. | ||||||||||
| 73 | |||||||||||
| 74 | =head2 metadata | ||||||||||
| 75 | |||||||||||
| 76 | A hash reference containing arbitrary metadata about the BSON document. | ||||||||||
| 77 | Default is C<undef>. | ||||||||||
| 78 | |||||||||||
| 79 | =head1 AUTHORS | ||||||||||
| 80 | |||||||||||
| 81 | =over 4 | ||||||||||
| 82 | |||||||||||
| 83 | =item * | ||||||||||
| 84 | |||||||||||
| 85 | David Golden <david@mongodb.com> | ||||||||||
| 86 | |||||||||||
| 87 | =item * | ||||||||||
| 88 | |||||||||||
| 89 | Stefan G. <minimalist@lavabit.com> | ||||||||||
| 90 | |||||||||||
| 91 | =back | ||||||||||
| 92 | |||||||||||
| 93 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 94 | |||||||||||
| 95 | This software is Copyright (c) 2020 by Stefan G. and MongoDB, Inc. | ||||||||||
| 96 | |||||||||||
| 97 | This is free software, licensed under: | ||||||||||
| 98 | |||||||||||
| 99 | The Apache License, Version 2.0, January 2004 | ||||||||||
| 100 | |||||||||||
| 101 | =cut | ||||||||||
| 102 | |||||||||||
| 103 | __END__ | ||||||||||