1 package MooseX::AttributeHelpers::Bool;
3 use MooseX::AttributeHelpers::MethodProvider::Bool;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 extends 'MooseX::AttributeHelpers::Base';
11 sub helper_type { 'Bool' }
14 # we don't use the method provider for this
15 # module since many of the names of the provied
16 # methods would conflict with keywords
19 has '+method_provider' => (
20 default => 'MooseX::AttributeHelpers::MethodProvider::Bool'
25 # register the alias ...
26 package # hide me from search.cpan.org
27 Moose::Meta::Attribute::Custom::Bool;
28 sub register_implementation { 'MooseX::AttributeHelpers::Bool' }
36 MooseX::AttributeHelpers::Bool
42 use MooseX::AttributeHelpers;
52 toggle => 'flip_switch',
57 my $room = Room->new();
58 $room->illuminate; # same as $room->is_lit(1);
59 $room->darken; # same as $room->is_lit(0);
60 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
61 return $room->is_dark; # same as !$room->is_lit
65 This provides a simple boolean attribute, which supports most of the
66 basic math operations.
76 =item B<method_constructors>
78 =item B<has_method_provider>
80 =item B<method_provider>
84 =head1 PROVIDED METHODS
86 It is important to note that all those methods do in place
87 modification of the value stored in the attribute.
93 Sets the value to C<1>.
97 Set the value to C<0>.
101 Toggle the value. If it's true, set to false, and vice versa.
105 Equivalent of 'not C<$value>'.
111 All complex software has bugs lurking in it, and this module is no
112 exception. If you find a bug please either email me, or add the bug
119 =head1 COPYRIGHT AND LICENSE
121 Copyright 2007-2008 by Infinity Interactive, Inc.
123 L<http://www.iinteractive.com>
125 This library is free software; you can redistribute it and/or modify
126 it under the same terms as Perl itself.