1 package Moose::Meta::Attribute::Native::Trait::Bool;
5 $VERSION = eval $VERSION;
6 our $AUTHORITY = 'cpan:STEVAN';
8 use Moose::Meta::Method::Accessor::Native::Bool::not;
9 use Moose::Meta::Method::Accessor::Native::Bool::set;
10 use Moose::Meta::Method::Accessor::Native::Bool::toggle;
11 use Moose::Meta::Method::Accessor::Native::Bool::unset;
13 with 'Moose::Meta::Attribute::Native::Trait';
15 sub _default_is { 'rw' }
16 sub _helper_type { 'Bool' }
26 Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
41 flip_switch => 'toggle',
46 my $room = Room->new();
47 $room->illuminate; # same as $room->is_lit(1);
48 $room->darken; # same as $room->is_lit(0);
49 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
50 return $room->is_dark; # same as !$room->is_lit
54 This trait provides native delegation methods for boolean values. A boolean is
55 a scalar which can be C<1>, C<0>, C<"">, or C<undef>.
59 If you don't provide an C<isa> value for your attribute, it will default to
62 =head1 PROVIDED METHODS
64 None of these methods accept arguments.
70 Sets the value to C<1> and returns C<1>.
74 Set the value to C<0> and returns C<0>.
78 Toggles the value. If it's true, set to false, and vice versa.
80 Returns the new value.
84 Equivalent of 'not C<$value>'.
90 See L<Moose/BUGS> for details on reporting bugs.
96 =head1 COPYRIGHT AND LICENSE
98 Copyright 2007-2009 by Infinity Interactive, Inc.
100 L<http://www.iinteractive.com>
102 This library is free software; you can redistribute it and/or modify
103 it under the same terms as Perl itself.