1 package Moose::Meta::Attribute::Native::Trait::Bool;
4 with 'Moose::Meta::Attribute::Native::Trait';
6 sub _default_is { 'rw' }
7 sub _helper_type { 'Bool' }
13 # ABSTRACT: Helper trait for Bool attributes
32 flip_switch => 'toggle',
37 my $room = Room->new();
38 $room->illuminate; # same as $room->is_lit(1);
39 $room->darken; # same as $room->is_lit(0);
40 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
41 return $room->is_dark; # same as !$room->is_lit
45 This trait provides native delegation methods for boolean values. A boolean is
46 a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
50 If you don't provide an C<isa> value for your attribute, it will default to
53 =head1 PROVIDED METHODS
55 None of these methods accept arguments.
61 Sets the value to C<1> and returns C<1>.
65 Set the value to C<0> and returns C<0>.
69 Toggles the value. If it's true, set to false, and vice versa.
71 Returns the new value.
75 Equivalent of 'not C<$value>'.
81 See L<Moose/BUGS> for details on reporting bugs.