1MooseX::AttributeHelperUss(e3rpmC)ontributed Perl DocumeMnotoasteiXo:n:AttributeHelpers(3pm)
2
3
4

NAME

6       MooseX::AttributeHelpers - (DEPRECATED) Extend your attribute
7       interfaces
8

VERSION

10       version 0.25
11

SYNOPSIS

13         package MyClass;
14         use Moose;
15         use MooseX::AttributeHelpers;
16
17         has 'mapping' => (
18             metaclass => 'Collection::Hash',
19             is        => 'rw',
20             isa       => 'HashRef[Str]',
21             default   => sub { {} },
22             provides  => {
23                 exists    => 'exists_in_mapping',
24                 keys      => 'ids_in_mapping',
25                 get       => 'get_mapping',
26                 set       => 'set_mapping',
27             },
28             curries  => {
29                 set       => { set_quantity => [ 'quantity' ] }
30             }
31         );
32
33
34         # ...
35
36         my $obj = MyClass->new;
37         $obj->set_quantity(10);      # quantity => 10
38         $obj->set_mapping(4, 'foo'); # 4 => 'foo'
39         $obj->set_mapping(5, 'bar'); # 5 => 'bar'
40         $obj->set_mapping(6, 'baz'); # 6 => 'baz'
41
42
43         # prints 'bar'
44         print $obj->get_mapping(5) if $obj->exists_in_mapping(5);
45
46         # prints '4, 5, 6'
47         print join ', ', $obj->ids_in_mapping;
48

DESCRIPTION

50       This distribution is deprecated. The features it provides have been
51       added to the Moose core code as Moose::Meta::Attribute::Native. This
52       distribution should not be used by any new code.
53
54       While Moose attributes provide you with a way to name your accessors,
55       readers, writers, clearers and predicates, this library provides
56       commonly used attribute helper methods for more specific types of data.
57
58       As seen in the "SYNOPSIS", you specify the extension via the
59       "metaclass" parameter. Available meta classes are:
60

PARAMETERS

62   provides
63       This points to a hashref that uses "provider" for the keys and "method"
64       for the values.  The method will be added to the object itself and do
65       what you want.
66
67   curries
68       This points to a hashref that uses "provider" for the keys and has two
69       choices for the value:
70
71       You can supply "{method => [ @args ]}" for the values.  The method will
72       be added to the object itself (always using @args as the beginning
73       arguments).
74
75       Another approach to curry a method provider is to supply a coderef
76       instead of an arrayref. The code ref takes $self, $body, and any
77       additional arguments passed to the final method.
78
79         # ...
80
81         curries => {
82             grep => {
83                 times_with_day => sub {
84                     my ($self, $body, $datetime) = @_;
85                     $body->($self, sub { $_->ymd eq $datetime->ymd });
86                 }
87             }
88         }
89
90         # ...
91
92         $obj->times_with_day(DateTime->now); # takes datetime argument, checks day
93

METHOD PROVIDERS

95       Number
96           Common numerical operations.
97
98       String
99           Common methods for string operations.
100
101       Counter
102           Methods for incrementing and decrementing a counter attribute.
103
104       Bool
105           Common methods for boolean values.
106
107       Collection::Hash
108           Common methods for hash references.
109
110       Collection::ImmutableHash
111           Common methods for inspecting hash references.
112
113       Collection::Array
114           Common methods for array references.
115
116       Collection::List
117           Common list methods for array references.
118

DEPRECATION NOTICE

120       The functionality in this family of modules is now implemented in the
121       Moose core as Moose::Meta::Attribute::Native.  No more development is
122       being done on MooseX::AttributeHelpers, so we encourage you to switch
123       to native attribute traits.
124

SUPPORT

126       Bugs may be submitted through the RT bug tracker
127       <https://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-
128       AttributeHelpers> (or bug-MooseX-AttributeHelpers@rt.cpan.org
129       <mailto:bug-MooseX-AttributeHelpers@rt.cpan.org>).
130
131       There is also a mailing list available for users of this distribution,
132       at <http://lists.perl.org/list/moose.html>.
133
134       There is also an irc channel available for users of this distribution,
135       at "#moose" on "irc.perl.org" <irc://irc.perl.org/#moose>.
136

AUTHOR

138       Stevan Little <stevan@iinteractive.com>
139

CONTRIBUTORS

141       ·   Shawn M Moore <sartak@gmail.com>
142
143       ·   Stevan Little <stevan.little@iinteractive.com>
144
145       ·   Dave Rolsky <autarch@urth.org>
146
147       ·   Florian Ragwitz <rafl@debian.org>
148
149       ·   Yuval Kogman <nothingmuch@woobling.org>
150
151       ·   Jason May <jason.a.may@gmail.com>
152
153       ·   Karen Etheridge <ether@cpan.org>
154
155       ·   Cory G Watson <gphat@onemogin.com>
156
157       ·   Jesse Luehrs <doy@tozt.net>
158
159       ·   Robert Boone <robo4288@gmail.com>
160
161       ·   Bruno Vecchi <vecchi.b@gmail.com>
162
163       ·   Johannes Plunien <plu@pqpq.de>
164
165       ·   Mike Whitaker <mike@altrion.org>
166
167       ·   Hans Dieter Pearcey <hdp@weftsoar.net>
168
169       ·   Paul Driver <frodwith@gmail.com>
170
171       ·   Robert 'phaylon' Sedlacek <rs@474.at>
172
173       ·   Evan Carroll <me@evancarroll.com>
174
175       ·   Dagfinn Ilmari Mannsaaker <ilmari@ilmari.org>
176
177       ·   Chris Prather <cprather@hdpublishing.com>
178
179       ·   Tom Lanyon <tom@netspot.com.au>
180
181       ·   Chris Prather <chris@prather.org>
182
183       ·   nperez <nperez@cpan.org>
184
186       This software is copyright (c) 2007 by Stevan Little and Infinity
187       Interactive, Inc.
188
189       This is free software; you can redistribute it and/or modify it under
190       the same terms as the Perl 5 programming language system itself.
191
192
193
194perl v5.32.0                      2020-07-28     MooseX::AttributeHelpers(3pm)
Impressum