blib/lib/Qless/Utils.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 9 | 16 | 56.2 |
branch | 0 | 4 | 0.0 |
condition | 0 | 3 | 0.0 |
subroutine | 3 | 4 | 75.0 |
pod | 0 | 1 | 0.0 |
total | 12 | 28 | 42.8 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | package Qless::Utils; | ||||||
2 | 1 | 1 | 4 | use strict; use warnings; | |||
1 | 1 | 2 | |||||
1 | 23 | ||||||
1 | 3 | ||||||
1 | 2 | ||||||
1 | 19 | ||||||
3 | |||||||
4 | 1 | 1 | 4 | use base 'Exporter'; | |||
1 | 1 | ||||||
1 | 179 | ||||||
5 | our @EXPORT_OK = qw(fix_empty_array); | ||||||
6 | |||||||
7 | # Because of how Lua parses JSON, empty arrays comes through as {} | ||||||
8 | sub fix_empty_array { | ||||||
9 | 0 | 0 | 0 | my $val = shift; | |||
10 | |||||||
11 | 0 | 0 | if (!$val) { | ||||
12 | 0 | return []; | |||||
13 | } | ||||||
14 | |||||||
15 | 0 | 0 | 0 | if (ref $val eq 'HASH' && !scalar keys %{ $val }) { | |||
0 | |||||||
16 | 0 | return []; | |||||
17 | } | ||||||
18 | |||||||
19 | 0 | return $val; | |||||
20 | } | ||||||
21 | |||||||
22 | 1; |