Skip to content

Commit 4cb01be

Browse files
committed
add MetaCPAN::Util::to_bool
This simplifies converting to a JSON boolean.
1 parent 5691cb1 commit 4cb01be

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/MetaCPAN/Util.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,21 @@ use Sub::Exporter -setup => {
3737
true
3838
false
3939
is_bool
40+
to_bool
4041
MAX_RESULT_WINDOW
4142
) ]
4243
};
4344

4445
# Limit the maximum result window to 1000, really should be enough!
4546
use constant MAX_RESULT_WINDOW => 1000;
4647

47-
*true = \&Cpanel::JSON::XS::true;
48-
*false = \&Cpanel::JSON::XS::false;
48+
sub true ();
49+
*true = \&Cpanel::JSON::XS::true;
50+
sub false ();
51+
*false = \&Cpanel::JSON::XS::false;
52+
sub is_bool ($);
4953
*is_bool = \&Cpanel::JSON::XS::is_bool;
54+
sub to_bool ($) { $_[0] ? true : false }
5055

5156
sub root_dir {
5257
Cwd::abs_path( File::Spec->catdir(

0 commit comments

Comments
 (0)