File: Bool.pod

package info (click to toggle)
libsub-handlesvia-perl 0.052000-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,740 kB
  • sloc: perl: 9,645; makefile: 2
file content (93 lines) | stat: -rw-r--r-- 1,973 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
=head1 NAME

Sub::HandlesVia::HandlerLibrary::Bool - library of bool-related methods

=head1 SYNOPSIS

  package My::Class {
    use Moo;
    use Sub::HandlesVia;
    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.