1 package Moose::AttributeHelpers::Trait::Bool;
3 use Moose::AttributeHelpers::MethodProvider::Bool;
6 $VERSION = eval $VERSION;
7 our $AUTHORITY = 'cpan:STEVAN';
9 with 'Moose::AttributeHelpers::Trait::Base';
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::AttributeHelpers::MethodProvider::Bool'
26 package # hide me from search.cpan.org
27 Moose::Meta::Attribute::Custom::Trait::Bool;
28 sub register_implementation { 'Moose::AttributeHelpers::Trait::Bool' }
36 Moose::AttributeHelpers::Bool
42 use Moose::AttributeHelpers;
52 flip_switch => 'toggle',
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.
74 =item B<method_constructors>
76 =item B<has_method_provider>
78 =item B<method_provider>
82 =head1 PROVIDED METHODS
84 It is important to note that all those methods do in place
85 modification of the value stored in the attribute.
91 Sets the value to C<1>.
95 Set the value to C<0>.
99 Toggle the value. If it's true, set to false, and vice versa.
103 Equivalent of 'not C<$value>'.
109 All complex software has bugs lurking in it, and this module is no
110 exception. If you find a bug please either email me, or add the bug
117 =head1 COPYRIGHT AND LICENSE
119 Copyright 2007-2009 by Infinity Interactive, Inc.
121 L<http://www.iinteractive.com>
123 This library is free software; you can redistribute it and/or modify
124 it under the same terms as Perl itself.