| 1 | package Mango::BSON::Document; | ||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use Mojo::Base 'Tie::Hash'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | sub DELETE { | ||||||||||||||||||||||||||
|
Subroutine
DELETE: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 5 | 2 | my ($self, $key) = @_; | |||||||||||||||||||||||||||
| 6 | 2 | ▶ | return undef unless exists $self->[0]{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 7 | 1 | $key eq $self->[1][$_] and splice @{$self->[1]}, $_, 1 and last | |||||||||||||||||||||||||||
| 8 | 1 | ▶ | for 0 .. $#{$self->[1]}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$key eq $self->[1][$_] and splice @{$$self[1];}, $_, 1
MC/DC50%1/2
$key eq $self->[1][$_] and splice @{$$self[1];}, $_, 1
$key eq $self->[1][$_]
splice @{$$self[1];}, $_, 1
Truth table66%2/3
A and B
A= $key eq $self->[1][$_]B= splice @{$$self[1];}, $_, 1
| |||||||||||||||||||||||||||||
| 9 | 1 | return delete $self->[0]{$key}; | |||||||||||||||||||||||||||
| 10 | } | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 110 | ▶ | sub EXISTS { exists $_[0][0]{$_[1]} } | ||||||||||||||||||||||||||
|
Subroutine
EXISTS: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 177 | ▶ | sub FETCH { $_[0][0]{$_[1]} } | ||||||||||||||||||||||||||
|
Subroutine
FETCH: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 125 | ▶ | sub FIRSTKEY { | ||||||||||||||||||||||||||
|
Subroutine
FIRSTKEY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 125 | $_[0][2] = 0; | |||||||||||||||||||||||||||
| 18 | 125 | &NEXTKEY; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 284 | ▶ | sub NEXTKEY { $_[0][2] <= $#{$_[0][1]} ? $_[0][1][$_[0][2]++] : undef } | ||||||||||||||||||||||||||
|
Subroutine
NEXTKEY: called CC=2 SCAR=6.9
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 112 | ▶ | sub STORE { | ||||||||||||||||||||||||||
|
Subroutine
STORE: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 24 | 112 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||
| 25 | 112 | ▶ | push @{$self->[1]}, $key unless exists $self->[0]{$key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 112 | $self->[0]{$key} = $value; | |||||||||||||||||||||||||||
| 27 | } | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 91 | ▶ | sub TIEHASH { | ||||||||||||||||||||||||||
|
Subroutine
TIEHASH: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 30 | 91 | my $self = bless [{}, [], 0], shift; | |||||||||||||||||||||||||||
| 31 | 91 | ▶ | $self->STORE(shift, shift) while @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | 91 | return $self; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 11 | 1; | |||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||
| 37 | =encoding utf8 | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =head1 NAME | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | Mango::BSON::Document - Document type | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | use Mango::BSON::Document; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | tie my %hash, 'Mango::BSON::Document'; | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | L<Mango::BSON::Document> is a container for the BSON document type used by | ||||||||||||||||||||||||||||
| 52 | L<Mango::BSON>. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | L<Mango>, L<Mojolicious::Guides>, L<http://mojolicio.us>. | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | =cut | ||||||||||||||||||||||||||||