The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

=head1 NAME
Sub::HandlesVia::HandlerLibrary::Bool - library of bool-related methods
=head1 SYNOPSIS
package My::Class {
use Moo;
use Types::Standard 'Bool';
has attr => (
is => 'rwp',
isa => Bool,
handles_via => 'Bool',
handles => {
'my_not' => 'not',
'my_reset' => 'reset',
'my_set' => 'set',
'my_toggle' => 'toggle',
'my_unset' => 'unset',
},
);
}
=head1 DESCRIPTION
This is a library of methods for L<Sub::HandlesVia>.
=head1 DELEGATABLE METHODS
=head2 C<< not() >>
Returns the opposite value of the boolean.
my $object = My::Class->new( attr => 1 );
say $object->my_not(); ## ==> false
=head2 C<< reset() >>
Sets the boolean to its default value, or false if it has no default.
=head2 C<< set() >>
Sets the value of the boolean to true.
my $object = My::Class->new();
$object->my_set();
say $object->attr; ## ==> true
=head2 C<< toggle() >>
Toggles the truth value of the boolean.
my $object = My::Class->new();
$object->my_toggle();
say $object->attr; ## ==> true
$object->my_toggle();
say $object->attr; ## ==> false
=head2 C<< unset() >>
Sets the value of the boolean to false.
my $object = My::Class->new();
$object->my_unset();
say $object->attr; ## ==> false
=head1 BUGS
Please report any bugs to
L<https://github.com/tobyink/p5-sub-handlesvia/issues>.
=head1 SEE ALSO
L<Sub::HandlesVia>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT AND LICENCE
This software is copyright (c) 2020, 2022 by Toby Inkster.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
=head1 DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.