File Coverage

blib/lib/BSON/Raw.pm
Criterion Covered Total %
statement 21 21 100.0
branch 1 2 50.0
condition n/a
subroutine 7 7 100.0
pod n/a
total 29 30 96.6


line stmt bran cond sub pod time code
1 71     71   25774 use 5.010001;
  71         223  
2 71     71   366 use strict;
  71         146  
  71         1430  
3 71     71   335 use warnings;
  71         178  
  71         2526  
4              
5             package BSON::Raw;
6             # ABSTRACT: BSON type wrapper for pre-encoded BSON documents
7              
8 71     71   574 use version;
  71         208  
  71         374  
9             our $VERSION = 'v1.12.1';
10              
11 71     71   5419 use Moo;
  71         143  
  71         384  
12              
13             #pod =attr bson
14             #pod
15             #pod A string containing a BSON-encoded document. Default is C.
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.
21             #pod
22             #pod =cut
23              
24             has [qw/bson metadata/] => (
25             is => 'ro'
26             );
27              
28 71     71   23692 use namespace::clean -except => 'meta';
  71         237  
  71         519  
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.
32             sub _get_first_key {
33 1     1   1071 my ($self) = @_;
34              
35 1 50       7 return undef if length( $self->bson ) <= 5; ## no critic
36              
37 1         9 my ( undef, undef, $key ) = unpack( "lCZ*", $self->bson );
38 1         3 return $key;
39             }
40              
41             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.1
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 or other client libraries.
67              
68             =head1 ATTRIBUTES
69              
70             =head2 bson
71              
72             A string containing a BSON-encoded document. Default is C.
73              
74             =head2 metadata
75              
76             A hash reference containing arbitrary metadata about the BSON document.
77             Default is C.
78              
79             =head1 AUTHORS
80              
81             =over 4
82              
83             =item *
84              
85             David Golden
86              
87             =item *
88              
89             Stefan G.
90              
91             =back
92              
93             =head1 COPYRIGHT AND LICENSE
94              
95             This software is Copyright (c) 2019 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__