line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
9
|
|
|
9
|
|
977
|
use 5.008; |
|
9
|
|
|
|
|
33
|
|
2
|
9
|
|
|
9
|
|
55
|
use strict; |
|
9
|
|
|
|
|
19
|
|
|
9
|
|
|
|
|
213
|
|
3
|
9
|
|
|
9
|
|
46
|
use warnings; |
|
9
|
|
|
|
|
18
|
|
|
9
|
|
|
|
|
645
|
|
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
package Sub::HandlesVia::HandlerLibrary::Bool; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
8
|
|
|
|
|
|
|
our $VERSION = '0.050000'; |
9
|
|
|
|
|
|
|
|
10
|
9
|
|
|
9
|
|
3432
|
use Sub::HandlesVia::HandlerLibrary; |
|
9
|
|
|
|
|
29
|
|
|
9
|
|
|
|
|
433
|
|
11
|
|
|
|
|
|
|
our @ISA = 'Sub::HandlesVia::HandlerLibrary'; |
12
|
|
|
|
|
|
|
|
13
|
9
|
|
|
9
|
|
69
|
use Sub::HandlesVia::Handler qw( handler ); |
|
9
|
|
|
|
|
22
|
|
|
9
|
|
|
|
|
66
|
|
14
|
|
|
|
|
|
|
our @METHODS = qw( set unset toggle not reset ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub set { |
17
|
|
|
|
|
|
|
handler |
18
|
|
|
|
|
|
|
name => 'Bool:set', |
19
|
|
|
|
|
|
|
args => 0, |
20
|
|
|
|
|
|
|
template => '« !!1 »', |
21
|
|
|
|
|
|
|
documentation => 'Sets the value of the boolean to true.', |
22
|
|
|
|
|
|
|
_examples => sub { |
23
|
1
|
|
|
1
|
|
79
|
my ( $class, $attr, $method ) = @_; |
24
|
1
|
|
|
|
|
7
|
return join "", |
25
|
|
|
|
|
|
|
" my \$object = $class\->new();\n", |
26
|
|
|
|
|
|
|
" \$object->$method\();\n", |
27
|
|
|
|
|
|
|
" say \$object->$attr; ## ==> true\n", |
28
|
|
|
|
|
|
|
"\n"; |
29
|
|
|
|
|
|
|
}, |
30
|
35
|
|
|
35
|
1
|
295
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub unset { |
33
|
|
|
|
|
|
|
handler |
34
|
|
|
|
|
|
|
name => 'Bool:unset', |
35
|
|
|
|
|
|
|
args => 0, |
36
|
|
|
|
|
|
|
template => '« !!0 »', |
37
|
|
|
|
|
|
|
documentation => 'Sets the value of the boolean to false.', |
38
|
|
|
|
|
|
|
_examples => sub { |
39
|
1
|
|
|
1
|
|
65
|
my ( $class, $attr, $method ) = @_; |
40
|
1
|
|
|
|
|
7
|
return join "", |
41
|
|
|
|
|
|
|
" my \$object = $class\->new();\n", |
42
|
|
|
|
|
|
|
" \$object->$method\();\n", |
43
|
|
|
|
|
|
|
" say \$object->$attr; ## ==> false\n", |
44
|
|
|
|
|
|
|
"\n"; |
45
|
|
|
|
|
|
|
}, |
46
|
35
|
|
|
35
|
1
|
308
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub toggle { |
49
|
|
|
|
|
|
|
handler |
50
|
|
|
|
|
|
|
name => 'Bool:toggle', |
51
|
|
|
|
|
|
|
args => 0, |
52
|
|
|
|
|
|
|
template => '« !$GET »', |
53
|
|
|
|
|
|
|
documentation => 'Toggles the truth value of the boolean.', |
54
|
|
|
|
|
|
|
_examples => sub { |
55
|
1
|
|
|
1
|
|
64
|
my ( $class, $attr, $method ) = @_; |
56
|
1
|
|
|
|
|
9
|
return join "", |
57
|
|
|
|
|
|
|
" my \$object = $class\->new();\n", |
58
|
|
|
|
|
|
|
" \$object->$method\();\n", |
59
|
|
|
|
|
|
|
" say \$object->$attr; ## ==> true\n", |
60
|
|
|
|
|
|
|
" \$object->$method\();\n", |
61
|
|
|
|
|
|
|
" say \$object->$attr; ## ==> false\n", |
62
|
|
|
|
|
|
|
"\n"; |
63
|
|
|
|
|
|
|
}, |
64
|
35
|
|
|
35
|
1
|
282
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
sub not { |
67
|
|
|
|
|
|
|
handler |
68
|
|
|
|
|
|
|
name => 'Bool:not', |
69
|
|
|
|
|
|
|
args => 0, |
70
|
|
|
|
|
|
|
template => '!$GET', |
71
|
|
|
|
|
|
|
documentation => 'Returns the opposite value of the boolean.', |
72
|
|
|
|
|
|
|
_examples => sub { |
73
|
1
|
|
|
1
|
|
64
|
my ( $class, $attr, $method ) = @_; |
74
|
1
|
|
|
|
|
6
|
return join "", |
75
|
|
|
|
|
|
|
" my \$object = $class\->new( $attr => 1 );\n", |
76
|
|
|
|
|
|
|
" say \$object->$method\(); ## ==> false\n", |
77
|
|
|
|
|
|
|
"\n"; |
78
|
|
|
|
|
|
|
}, |
79
|
35
|
|
|
35
|
1
|
266
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub reset { |
82
|
|
|
|
|
|
|
handler |
83
|
|
|
|
|
|
|
name => 'Bool:reset', |
84
|
|
|
|
|
|
|
args => 0, |
85
|
|
|
|
|
|
|
template => '« $DEFAULT »', |
86
|
0
|
|
|
0
|
|
0
|
default_for_reset => sub { 0 }, |
87
|
3
|
|
|
3
|
1
|
36
|
documentation => 'Sets the boolean to its default value, or false if it has no default.', |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; |