update documentation for Array so I can run it past confound and doy before doing...
[gitmo/Moose.git] / lib / Moose / Meta / Attribute / Native / Trait / Bool.pm
CommitLineData
c466e58f 1package Moose::Meta::Attribute::Native::Trait::Bool;
e3c07b19 2use Moose::Role;
c466e58f 3use Moose::Meta::Attribute::Native::MethodProvider::Bool;
e3c07b19 4
96539d20 5our $VERSION = '0.87';
e3c07b19 6$VERSION = eval $VERSION;
7our $AUTHORITY = 'cpan:STEVAN';
8
c466e58f 9with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 10
2edb73d9 11sub _default_is { 'rw' }
2e069f5a 12sub _helper_type { 'Bool' }
2edb73d9 13
a65d8455 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
e3c07b19 16
17has 'method_provider' => (
18 is => 'ro',
19 isa => 'ClassName',
20 predicate => 'has_method_provider',
c466e58f 21 default => 'Moose::Meta::Attribute::Native::MethodProvider::Bool'
e3c07b19 22);
23
e3c07b19 24no Moose::Role;
25
e3c07b19 261;
27
28=pod
29
30=head1 NAME
31
c466e58f 32Moose::Meta::Attribute::Native::Trait::Bool
e3c07b19 33
34=head1 SYNOPSIS
35
36 package Room;
37 use Moose;
38 use Moose::AttributeHelpers;
39
40 has 'is_lit' => (
41 metaclass => 'Bool',
42 is => 'rw',
43 isa => 'Bool',
2edb73d9 44 default => 0,
5f3663b2 45 handles => {
46 illuminate => 'set',
47 darken => 'unset',
48 flip_switch => 'toggle',
49 is_dark => 'not',
e3c07b19 50 }
51 );
52
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
58
59=head1 DESCRIPTION
60
61This provides a simple boolean attribute, which supports most of the
62basic math operations.
63
64=head1 METHODS
65
66=over 4
67
68=item B<meta>
69
e3c07b19 70=item B<method_constructors>
71
72=item B<has_method_provider>
73
74=item B<method_provider>
75
76=back
77
78=head1 PROVIDED METHODS
79
80It is important to note that all those methods do in place
81modification of the value stored in the attribute.
82
83=over 4
84
85=item I<set>
86
87Sets the value to C<1>.
88
89=item I<unset>
90
91Set the value to C<0>.
92
93=item I<toggle>
94
95Toggle the value. If it's true, set to false, and vice versa.
96
97=item I<not>
98
99Equivalent of 'not C<$value>'.
100
101=back
102
103=head1 BUGS
104
105All complex software has bugs lurking in it, and this module is no
106exception. If you find a bug please either email me, or add the bug
107to cpan-RT.
108
109=head1 AUTHOR
110
111Jason May
112
113=head1 COPYRIGHT AND LICENSE
114
115Copyright 2007-2009 by Infinity Interactive, Inc.
116
117L<http://www.iinteractive.com>
118
119This library is free software; you can redistribute it and/or modify
120it under the same terms as Perl itself.
121
122=cut