1 package MooseX::AttributeHelpers::Bool;
3 use MooseX::AttributeHelpers::MethodProvider::Bool;
6 our $AUTHORITY = 'cpan:STEVAN';
8 extends 'MooseX::AttributeHelpers::Base';
10 sub helper_type { 'Bool' }
13 # we don't use the method provider for this
14 # module since many of the names of the provied
15 # methods would conflict with keywords
18 has '+method_provider' => (
19 default => 'MooseX::AttributeHelpers::MethodProvider::Bool'
24 # register the alias ...
25 package # hide me from search.cpan.org
26 Moose::Meta::Attribute::Custom::Bool;
27 sub register_implementation { 'MooseX::AttributeHelpers::Bool' }
35 MooseX::AttributeHelpers::Bool
41 use MooseX::AttributeHelpers;
51 toggle => 'flip_switch',
56 my $room = Room->new();
57 $room->illuminate; # same as $room->is_lit(1);
58 $room->darken; # same as $room->is_lit(0);
59 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
60 return $room->is_dark; # same as !$room->is_lit
64 This provides a simple boolean attribute, which supports most of the
65 basic math operations.
75 =item B<method_constructors>
79 =head1 PROVIDED METHODS
81 It is important to note that all those methods do in place
82 modification of the value stored in the attribute.
88 Sets the value to C<1>.
92 Set the value to C<0>.
96 Toggle the value. If it's true, set to false, and vice versa.
100 Equivalent of 'not C<$value>'.
106 All complex software has bugs lurking in it, and this module is no
107 exception. If you find a bug please either email me, or add the bug
114 =head1 COPYRIGHT AND LICENSE
116 Copyright 2007-2008 by Infinity Interactive, Inc.
118 L<http://www.iinteractive.com>
120 This library is free software; you can redistribute it and/or modify
121 it under the same terms as Perl itself.