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' }
18 sub _native_type { 'Bool' }
28 Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool attributes
43 flip_switch => 'toggle',
48 my $room = Room->new();
49 $room->illuminate; # same as $room->is_lit(1);
50 $room->darken; # same as $room->is_lit(0);
51 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
52 return $room->is_dark; # same as !$room->is_lit
56 This provides a simple boolean attribute, which supports most of the
57 basic math operations.
59 =head1 PROVIDED METHODS
61 These methods are implemented in
62 L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
63 note that all those methods do in place modification of the value stored in
70 Sets the value to C<1>.
74 Set the value to C<0>.
78 Toggles the value. If it's true, set to false, and vice versa.
82 Equivalent of 'not C<$value>'.
92 =item B<has_method_provider>
94 =item B<method_provider>
100 See L<Moose/BUGS> for details on reporting bugs.
106 =head1 COPYRIGHT AND LICENSE
108 Copyright 2007-2009 by Infinity Interactive, Inc.
110 L<http://www.iinteractive.com>
112 This library is free software; you can redistribute it and/or modify
113 it under the same terms as Perl itself.