Bump to 0.13
[gitmo/MooseX-AttributeHelpers.git] / lib / MooseX / AttributeHelpers / Bool.pm
CommitLineData
063fae5e 1package MooseX::AttributeHelpers::Bool;
2use Moose;
3use MooseX::AttributeHelpers::MethodProvider::Bool;
4
18d43c2c 5our $VERSION = '0.13';
063fae5e 6our $AUTHORITY = 'cpan:STEVAN';
7
8extends 'MooseX::AttributeHelpers::Base';
9
10sub helper_type { 'Bool' }
11
12# NOTE:
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
16# - SL
17
18has '+method_provider' => (
19 default => 'MooseX::AttributeHelpers::MethodProvider::Bool'
20);
21
22no Moose;
23
24# register the alias ...
25package # hide me from search.cpan.org
26 Moose::Meta::Attribute::Custom::Bool;
27sub register_implementation { 'MooseX::AttributeHelpers::Bool' }
28
291;
30
31=pod
32
33=head1 NAME
34
35MooseX::AttributeHelpers::Bool
36
37=head1 SYNOPSIS
38
39 package Room;
40 use Moose;
41 use MooseX::AttributeHelpers;
42
43 has 'is_lit' => (
44 metaclass => 'Bool',
45 is => 'rw',
46 isa => 'Int',
47 default => sub { 0 },
48 provides => {
49 set => 'illuminate',
50 unset => 'darken',
51 toggle => 'flip_switch',
52 not => 'is_dark'
53 }
54 );
55
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
61
62=head1 DESCRIPTION
63
64This provides a simple boolean attribute, which supports most of the
65basic math operations.
66
67=head1 METHODS
68
69=over 4
70
71=item B<meta>
72
73=item B<helper_type>
74
75=item B<method_constructors>
76
77=back
78
79=head1 PROVIDED METHODS
80
81It is important to note that all those methods do in place
82modification of the value stored in the attribute.
83
84=over 4
85
86=item I<set>
87
88Sets the value to C<1>.
89
90=item I<unset>
91
92Set the value to C<0>.
93
94=item I<toggle>
95
96Toggle the value. If it's true, set to false, and vice versa.
97
98=item I<not>
99
100Equivalent of 'not C<$value>'.
101
102=back
103
104=head1 BUGS
105
106All complex software has bugs lurking in it, and this module is no
107exception. If you find a bug please either email me, or add the bug
108to cpan-RT.
109
110=head1 AUTHOR
111
112Jason May
113
114=head1 COPYRIGHT AND LICENSE
115
116Copyright 2007-2008 by Infinity Interactive, Inc.
117
118L<http://www.iinteractive.com>
119
120This library is free software; you can redistribute it and/or modify
121it under the same terms as Perl itself.
122
123=cut