| 1 | package API::Docker::Role::JSONBody; | ||||||||||
| 2 | # ABSTRACT: coerce known boolean keys of a request body to JSON booleans | ||||||||||
| 3 | 52 | our $VERSION = '0.006'; | |||||||||
| 4 | 52 | ▶ | use Moo::Role; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 52 | ▶ | use namespace::clean; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | |||||||||||
| 8 | 10 | ▶ | sub _json_bools { | ||||||||
|
Subroutine
_json_bools: called CC=5 SCAR=16.1
| |||||||||||
| 9 | 10 | my ($self, $hash, @keys) = @_; | |||||||||
| 10 | 10 | for my $key (@keys) { | |||||||||
| 11 | 47 | ▶ | next unless exists $hash->{$key}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 12 | 14 | my $value = $hash->{$key}; | |||||||||
| 13 | 14 | ▶ | next if ref $value; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 14 | 13 | ▶ | $hash->{$key} = $value ? \1 : \0; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 15 | } | ||||||||||
| 16 | 10 | return $hash; | |||||||||
| 17 | } | ||||||||||
| 18 | |||||||||||
| 19 | 52 | 1; | |||||||||
| 20 | |||||||||||
| 21 | __END__ | ||||||||||