| 1 | package Data::Perl::Role::Bool; | ||||||||||
| 2 | 9 | $Data::Perl::Role::Bool::VERSION = '0.002011'; | |||||||||
| 3 | # ABSTRACT: Wrapping class for boolean values. | ||||||||||
| 4 | |||||||||||
| 5 | 9 | ▶ | use strictures 1; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 9 | ▶ | use Role::Tiny; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 4 | ▶ | sub new { my $bool = $_[1] ? 1 : 0; bless(\$bool, $_[0]) } | ||||||||
|
Subroutine
new: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 10 | |||||||||||
| 11 | 2 | ▶ | sub set { ${$_[0]} = 1 } | ||||||||
|
Subroutine
set: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 12 | |||||||||||
| 13 | 1 | ▶ | sub unset { ${$_[0]} = 0 } | ||||||||
|
Subroutine
unset: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 14 | |||||||||||
| 15 | 3 | ▶ | sub toggle { ${$_[0]} = ${$_[0]} ? 0 : 1; } | ||||||||
|
Subroutine
toggle: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 2 | ▶ | sub not { !${$_[0]} } | ||||||||
|
Subroutine
not: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 18 | |||||||||||
| 19 | 9 | 1; | |||||||||
| 20 | |||||||||||
| 21 | =pod | ||||||||||
| 22 | |||||||||||
| 23 | =encoding UTF-8 | ||||||||||
| 24 | |||||||||||
| 25 | =head1 NAME | ||||||||||
| 26 | |||||||||||
| 27 | Data::Perl::Role::Bool - Wrapping class for boolean values. | ||||||||||
| 28 | |||||||||||
| 29 | =head1 VERSION | ||||||||||
| 30 | |||||||||||
| 31 | version 0.002011 | ||||||||||
| 32 | |||||||||||
| 33 | =head1 SYNOPSIS | ||||||||||
| 34 | |||||||||||
| 35 | use Data::Perl qw/bool/; | ||||||||||
| 36 | |||||||||||
| 37 | my $bool = bool(0); | ||||||||||
| 38 | |||||||||||
| 39 | $bool->toggle; # 1 | ||||||||||
| 40 | |||||||||||
| 41 | $bool->unset; # 0 | ||||||||||
| 42 | |||||||||||
| 43 | =head1 DESCRIPTION | ||||||||||
| 44 | |||||||||||
| 45 | This class provides a wrapper and methods for interacting with boolean values. | ||||||||||
| 46 | |||||||||||
| 47 | =head1 PROVIDED METHODS | ||||||||||
| 48 | |||||||||||
| 49 | None of these methods accept arguments. | ||||||||||
| 50 | |||||||||||
| 51 | =over 4 | ||||||||||
| 52 | |||||||||||
| 53 | =item B<new($value)> | ||||||||||
| 54 | |||||||||||
| 55 | Constructs a new Data::Perl::Collection::Bool object initialized with the passed | ||||||||||
| 56 | in value, and returns it. | ||||||||||
| 57 | |||||||||||
| 58 | =item B<set> | ||||||||||
| 59 | |||||||||||
| 60 | Sets the value to C<1> and returns C<1>. | ||||||||||
| 61 | |||||||||||
| 62 | =item B<unset> | ||||||||||
| 63 | |||||||||||
| 64 | Set the value to C<0> and returns C<0>. | ||||||||||
| 65 | |||||||||||
| 66 | =item B<toggle> | ||||||||||
| 67 | |||||||||||
| 68 | Toggles the value. If it's true, set to false, and vice versa. | ||||||||||
| 69 | |||||||||||
| 70 | Returns the new value. | ||||||||||
| 71 | |||||||||||
| 72 | =item B<not> | ||||||||||
| 73 | |||||||||||
| 74 | Equivalent of 'not C<$value>'. | ||||||||||
| 75 | |||||||||||
| 76 | =back | ||||||||||
| 77 | |||||||||||
| 78 | =head1 SEE ALSO | ||||||||||
| 79 | |||||||||||
| 80 | =over 4 | ||||||||||
| 81 | |||||||||||
| 82 | =item * L<Data::Perl> | ||||||||||
| 83 | |||||||||||
| 84 | =item * L<MooX::HandlesVia> | ||||||||||
| 85 | |||||||||||
| 86 | =back | ||||||||||
| 87 | |||||||||||
| 88 | =head1 AUTHOR | ||||||||||
| 89 | |||||||||||
| 90 | Matthew Phillips <mattp@cpan.org> | ||||||||||
| 91 | |||||||||||
| 92 | =head1 COPYRIGHT AND LICENSE | ||||||||||
| 93 | |||||||||||
| 94 | This software is copyright (c) 2020 by Matthew Phillips <mattp@cpan.org>. | ||||||||||
| 95 | |||||||||||
| 96 | This is free software; you can redistribute it and/or modify it under | ||||||||||
| 97 | the same terms as the Perl 5 programming language system itself. | ||||||||||
| 98 | |||||||||||
| 99 | =cut | ||||||||||
| 100 | |||||||||||
| 101 | __END__ | ||||||||||