| 1 | 11 | ▶ | use utf8; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 2 | 11 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 3 | 11 | ▶ | use warnings; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | package DR::Tnt::Msgpack::Types::Bool; | ||||||||||||||||||||
| 6 | 11 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 7 | 11 | $Carp::Internal{ (__PACKAGE__) }++; | |||||||||||||||||||
| 8 | 11 | ▶ | use Scalar::Util (); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 9 | 11 | ▶ | use feature 'state'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 10 | |||||||||||||||||||||
| 11 | sub new { | ||||||||||||||||||||
| 12 | 22 | ▶ | my ($class, $value) = @_; | ||||||||||||||||||
|
Subroutine
new: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||
| 13 | |||||||||||||||||||||
| 14 | 22 | ▶ | $value = $value ? 1 : 0; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 15 | 22 | ▶ | bless \$value => ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 16 | } | ||||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | sub TO_MSGPACK { | ||||||||||||||||||||
| 19 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
TO_MSGPACK: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 20 | 4 | ▶ | return pack 'C', 0xC3 if $$self; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 21 | 2 | return pack 'C', 0xC2; | |||||||||||||||||||
| 22 | } | ||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | sub TO_JSON { | ||||||||||||||||||||
| 25 | 4 | ▶ | my ($self) = @_; | ||||||||||||||||||
|
Subroutine
TO_JSON: called CC=5 SCAR=17.6
Pod
undocumented
| |||||||||||||||||||||
| 26 | |||||||||||||||||||||
| 27 | 4 | state ($true, $false); | |||||||||||||||||||
| 28 | |||||||||||||||||||||
| 29 | 4 | ▶ | unless (defined $true) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 30 | 1 | ▶ | if (eval "require JSON::XS; 1") { | ||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||
| 31 | 1 | $true = JSON::XS::true(); | |||||||||||||||||||
| 32 | 1 | $false = JSON::XS::false(); | |||||||||||||||||||
| 33 | } elsif (eval "require JSON; 1") { | ||||||||||||||||||||
| 34 | 0 | $true = JSON::true(); | |||||||||||||||||||
| 35 | 0 | $false = JSON::false(); | |||||||||||||||||||
| 36 | } else { | ||||||||||||||||||||
| 37 | 0 | croak "JSON or JSON::XS must be installed"; | |||||||||||||||||||
| 38 | } | ||||||||||||||||||||
| 39 | } | ||||||||||||||||||||
| 40 | |||||||||||||||||||||
| 41 | 4 | ▶ | return $true if $$self; | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 42 | 2 | return $false; | |||||||||||||||||||
| 43 | } | ||||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | =head1 NAME | ||||||||||||||||||||
| 46 | |||||||||||||||||||||
| 47 | DR::Tnt::Msgpack::Types::Bool - container for bool. | ||||||||||||||||||||
| 48 | |||||||||||||||||||||
| 49 | =head1 SYNOPSIS | ||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | use DR::Tnt::Msgpack::Types::Bool; | ||||||||||||||||||||
| 52 | |||||||||||||||||||||
| 53 | my $o = DR::Tnt::Msgpack::Types::Bool->new(1); | ||||||||||||||||||||
| 54 | my $blob = msgpack($o); | ||||||||||||||||||||
| 55 | |||||||||||||||||||||
| 56 | =head1 DESCRIPTION | ||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | See L<DR::Tnt::Msgpack::Types>. | ||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | =cut | ||||||||||||||||||||
| 61 | |||||||||||||||||||||
| 62 | 11 | 1; | |||||||||||||||||||