1MouseX::NativeTraits::BUosoelr(3C)ontributed Perl DocumeMnotuasteiXo:n:NativeTraits::Bool(3)
2
3
4

NAME

6       MouseX::NativeTraits::Bool - Helper trait for Bool attributes
7

SYNOPSIS

9         package Room;
10         use Mouse;
11
12         has 'is_lit' => (
13             traits    => ['Bool'],
14             is        => 'rw',
15             isa       => 'Bool',
16             default   => 0,
17             handles   => {
18                 illuminate  => 'set',
19                 darken      => 'unset',
20                 flip_switch => 'toggle',
21                 is_dark     => 'not',
22             },
23         );
24
25         my $room = Room->new();
26         $room->illuminate;     # same as $room->is_lit(1);
27         $room->darken;         # same as $room->is_lit(0);
28         $room->flip_switch;    # same as $room->is_lit(not $room->is_lit);
29         return $room->is_dark; # same as !$room->is_lit
30

DESCRIPTION

32       This provides a simple boolean attribute, which supports most of the
33       basic math operations.
34

PROVIDED METHODS

36       These methods are implemented in
37       MouseX::NativeTraits::MethodProvider::Bool. It is important to note
38       that all those methods do in place modification of the value stored in
39       the attribute.
40
41       set Sets the value to true.
42
43       unset
44           Set the value to false.
45
46       toggle
47           Toggles the value. If it's true, set to false, and vice versa.
48
49       not Equivalent of 'not $value'.
50

METHODS

52       meta
53       method_provider_class
54       helper_type
55

SEE ALSO

57       MouseX::NativeTraits.
58
59
60
61perl v5.36.0                      2023-01-20     MouseX::NativeTraits::Bool(3)
Impressum