1Moose::Meta::Attribute:U:sNeartiCvoen:t:rTiMrboauoitstee:d:::BPMoeeortlla(:3D:)oActutmreinbtuattei:o:nNative::Trait::Bool(3)
2
3
4
6 Moose::Meta::Attribute::Native::Trait::Bool - Helper trait for Bool
7 attributes
8
10 version 2.2012
11
13 package Room;
14 use Moose;
15
16 has 'is_lit' => (
17 traits => ['Bool'],
18 is => 'rw',
19 isa => 'Bool',
20 default => 0,
21 handles => {
22 illuminate => 'set',
23 darken => 'unset',
24 flip_switch => 'toggle',
25 is_dark => 'not',
26 },
27 );
28
29 my $room = Room->new();
30 $room->illuminate; # same as $room->is_lit(1);
31 $room->darken; # same as $room->is_lit(0);
32 $room->flip_switch; # same as $room->is_lit(not $room->is_lit);
33 return $room->is_dark; # same as !$room->is_lit
34
36 This trait provides native delegation methods for boolean values. A
37 boolean is a scalar which can be 1, 0, "", or "undef".
38
40 If you don't provide an "isa" value for your attribute, it will default
41 to "Bool".
42
44 None of these methods accept arguments.
45
46 · set
47
48 Sets the value to 1 and returns 1.
49
50 · unset
51
52 Set the value to 0 and returns 0.
53
54 · toggle
55
56 Toggles the value. If it's true, set to false, and vice versa.
57
58 Returns the new value.
59
60 · not
61
62 Equivalent of 'not $value'.
63
65 See "BUGS" in Moose for details on reporting bugs.
66
68 · Stevan Little <stevan.little@iinteractive.com>
69
70 · Dave Rolsky <autarch@urth.org>
71
72 · Jesse Luehrs <doy@tozt.net>
73
74 · Shawn M Moore <code@sartak.org>
75
76 · יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
77
78 · Karen Etheridge <ether@cpan.org>
79
80 · Florian Ragwitz <rafl@debian.org>
81
82 · Hans Dieter Pearcey <hdp@weftsoar.net>
83
84 · Chris Prather <chris@prather.org>
85
86 · Matt S Trout <mst@shadowcat.co.uk>
87
89 This software is copyright (c) 2006 by Infinity Interactive, Inc.
90
91 This is free software; you can redistribute it and/or modify it under
92 the same terms as the Perl 5 programming language system itself.
93
94
95
96perl v5.30.1 Mo2o0s2e0:-:0M1e-t3a0::Attribute::Native::Trait::Bool(3)