MouseX::NativeTraits::Bool3pm
Helper trait for bool attributes
Usage
package Room;use Mouse;has 'is_lit' => (traits => ['Bool'],is => 'rw',isa => 'Bool',default => 0,handles => {illuminate => 'set',darken => 'unset',flip_switch => 'toggle',is_dark => 'not',},);my $room = Room->new();$room->illuminate; # same as $room->is_lit(1);$room->darken; # same as $room->is_lit(0);$room->flip_switch; # same as $room->is_lit(not $room->is_lit);return $room->is_dark; # same as !$room->is_lit
Overview
This provides a simple boolean attribute, which supports most of the basic math operations.
Provided methods
These methods are implemented in MouseX::NativeTraits::MethodProvider::Bool. It is important to note that all those methods do in place modification of the value stored in the attribute.
|
Sets the value to true. |
|---|---|
|
Set the value to false. |
|
Toggles the value. If it's true, set to false, and vice versa. |
|
Equivalent of 'not |
Methods
meta
method_provider_class
helper_type
Releases
7 releases since Debian 7 (Wheezy); the text changed 3 times.