1 package Moose::Meta::Attribute::Native::Trait::Bool;
3 use Moose::Meta::Attribute::Native::MethodProvider::Bool;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 with 'Moose::Meta::Attribute::Native::Trait';
11 sub _default_is { 'rw' }
12 sub _helper_type { 'Bool' }
14 # NOTE: we don't use the method provider for this module since many of
15 # the names of the provided methods would conflict with keywords - SL
17 has 'method_provider' => (
20 predicate => 'has_method_provider',
21 default => 'Moose::Meta::Attribute::Native::MethodProvider::Bool'
32 Moose::Meta::Attribute::Native::Trait::Bool
38 use Moose::AttributeHelpers;
48 flip_switch => 'toggle',
53 my $room = Room->new();
54 $room->illuminate; # same as $room->is_lit(1);
55 $room->darken; # same as $room->is_lit(0);
56 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
57 return $room->is_dark; # same as !$room->is_lit
61 This provides a simple boolean attribute, which supports most of the
62 basic math operations.
64 =head1 PROVIDED METHODS
66 These methods are implemented in
67 L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
68 note that all those methods do in place modification of the value stored in
75 Sets the value to C<1>.
79 Set the value to C<0>.
83 Toggle the value. If it's true, set to false, and vice versa.
87 Equivalent of 'not C<$value>'.
97 =item B<method_constructors>
99 =item B<has_method_provider>
101 =item B<method_provider>
107 All complex software has bugs lurking in it, and this module is no
108 exception. If you find a bug please either email me, or add the bug
115 =head1 COPYRIGHT AND LICENSE
117 Copyright 2007-2009 by Infinity Interactive, Inc.
119 L<http://www.iinteractive.com>
121 This library is free software; you can redistribute it and/or modify
122 it under the same terms as Perl itself.