=encoding utf8 =head1 NAME Module::Generic::Boolean - Boolean Representation Class =head1 SYNOPSIS my $bool = Module::Generic::Boolean->true; # or my $bool = Module::Generic::Boolean::true; # Now I have a Module::Generic::Boolean object # Returns 1 if( $bool ) { # Do something } my $hash = { name => 'John Doe', active => $bool, }; # Converting to json print( JSON->new->encode( $hash ), "\n" ); # Would result in { name: "Jogn Doe", active: true } =head1 VERSION v1.1.1 =head1 DESCRIPTION This a class/package to represent boolean value and make sure they are recognised interchangeably as perl boolean, i.e. 1 or 0, or as L bool, i.e. C or C The code is taken and adapted from part of L module. =head1 METHODS =head2 as_array Returns an L object with the current boolean value as its only entry. my $true = Module::Generic::Boolean->true; my $a = $true->as_array; say $a->[0]; # 1 =head2 as_number Returns the current boolean value (1 or 0) as a L object. =head2 as_scalar Returns the current boolean value (1 or 0) as a L object. =head2 defined Returns true. =head2 true This returns a perl true value i.e. 1 or C when added into L =head2 false This returns a perl false value i.e. 0 or C when added into L =head2 is_bool Provided with a value and this returns true if it is a L object =head2 is_true Provided with a value and this returns true if it is a L object and this is true. =head2 is_false Provided with a value and this returns true if it is a L object and this is false. =head2 TO_JSON This is called by L to transform an object into json data format. It returns C<\1> if true, or C<\0> otherwise. Those values are understood by L and transcoded accordingly. =head1 SERIALISATION =for Pod::Coverage FREEZE =for Pod::Coverage STORABLE_freeze =for Pod::Coverage STORABLE_thaw =for Pod::Coverage THAW =for Pod::Coverage TO_JSON Serialisation by L, L and L (or the legacy L) is supported by this package. To that effect, the following subroutines are implemented: C, C, C and C =head1 AUTHOR Jacques Deguest EFE =head1 COPYRIGHT & LICENSE Copyright (c) 2000-2024 DEGUEST Pte. Ltd. You can use, copy, modify and redistribute this package and associated files under the same terms as Perl itself. =cut