Document length and substr, which are in the MethodProvider
[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
122a129a 5our $VERSION = '0.89';
e3c07b19 6$VERSION = eval $VERSION;
7our $AUTHORITY = 'cpan:STEVAN';
8
c466e58f 9with 'Moose::Meta::Attribute::Native::Trait';
e3c07b19 10
55a9d564 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;
e3c07b19 38
39 has 'is_lit' => (
9610c1d2 40 traits => ['Bool'],
e3c07b19 41 is => 'rw',
42 isa => 'Bool',
2edb73d9 43 default => 0,
5f3663b2 44 handles => {
45 illuminate => 'set',
46 darken => 'unset',
47 flip_switch => 'toggle',
48 is_dark => 'not',
9610c1d2 49 },
e3c07b19 50 );
51
52 my $room = Room->new();
53 $room->illuminate; # same as $room->is_lit(1);
54 $room->darken; # same as $room->is_lit(0);
55 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
56 return $room->is_dark; # same as !$room->is_lit
57
58=head1 DESCRIPTION
59
60This provides a simple boolean attribute, which supports most of the
61basic math operations.
62
e3c07b19 63=head1 PROVIDED METHODS
64
55a9d564 65These methods are implemented in
66L<Moose::Meta::Attribute::Native::MethodProvider::Bool>. It is important to
67note that all those methods do in place modification of the value stored in
68the attribute.
e3c07b19 69
70=over 4
71
72=item I<set>
73
74Sets the value to C<1>.
75
76=item I<unset>
77
78Set the value to C<0>.
79
80=item I<toggle>
81
157e0475 82Toggles the value. If it's true, set to false, and vice versa.
e3c07b19 83
84=item I<not>
85
86Equivalent of 'not C<$value>'.
87
88=back
89
55a9d564 90=head1 METHODS
91
92=over 4
93
94=item B<meta>
95
96=item B<method_constructors>
97
98=item B<has_method_provider>
99
100=item B<method_provider>
101
102=back
103
e3c07b19 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-2009 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