1MooseX::ClassAttribute(U3s)er Contributed Perl DocumentatMiooonseX::ClassAttribute(3)
2
3
4

NAME

6       MooseX::ClassAttribute - Declare class attributes Moose-style
7

VERSION

9       version 0.29
10

SYNOPSIS

12           package My::Class;
13
14           use Moose;
15           use MooseX::ClassAttribute;
16
17           class_has 'Cache' =>
18               ( is      => 'rw',
19                 isa     => 'HashRef',
20                 default => sub { {} },
21               );
22
23           __PACKAGE__->meta()->make_immutable();
24
25           no Moose;
26           no MooseX::ClassAttribute;
27
28           # then later ...
29
30           My::Class->Cache()->{thing} = ...;
31

DESCRIPTION

33       This module allows you to declare class attributes in exactly the same
34       way as object attributes, using "class_has()" instead of "has()".
35
36       You can use any feature of Moose's attribute declarations, including
37       overriding a parent's attributes, delegation ("handles"), attribute
38       traits, etc. All features should just work. The one exception is the
39       "required" flag, which is not allowed for class attributes.
40
41       The accessor methods for class attribute may be called on the class
42       directly, or on objects of that class. Passing a class attribute to the
43       constructor will not set that attribute.
44

FUNCTIONS

46       This class exports one function when you use it, "class_has()". This
47       works exactly like Moose's "has()", but it declares class attributes.
48
49       One little nit is that if you include "no Moose" in your class, you
50       won't remove the "class_has()" function. To do that you must include
51       "no MooseX::ClassAttribute" as well. Or you can just use
52       namespace::autoclean instead.
53
54   Implementation and Immutability
55       This module will add a role to your class's metaclass, See
56       MooseX::ClassAttribute::Trait::Class for details. This role provides
57       introspection methods for class attributes.
58
59       Class attributes themselves do the
60       MooseX::ClassAttribute::Trait::Attribute role.
61
62   Cooperation with Metaclasses and Traits
63       This module should work with most attribute metaclasses and traits, but
64       it's possible that conflicts could occur. This module has been tested
65       to work with Moose's native traits.
66
67   Class Attributes in Roles
68       You can add a class attribute to a role. When that role is applied to a
69       class, the class will have the relevant class attributes added. Note
70       that attribute defaults will be calculated when the class attribute is
71       composed into the class.
72

SUPPORT

74       Bugs may be submitted through the RT bug tracker
75       <http://rt.cpan.org/Public/Dist/Display.html?Name=MooseX-
76       ClassAttribute> (or bug-moosex-classattribute@rt.cpan.org <mailto:bug-
77       moosex-classattribute@rt.cpan.org>).
78
79       I am also usually active on IRC as 'drolsky' on "irc://irc.perl.org".
80

DONATIONS

82       If you'd like to thank me for the work I've done on this module, please
83       consider making a "donation" to me via PayPal. I spend a lot of free
84       time creating free software, and would appreciate any support you'd
85       care to offer.
86
87       Please note that I am not suggesting that you must do this in order for
88       me to continue working on this particular software. I will continue to
89       do so, inasmuch as I have in the past, for as long as it interests me.
90
91       Similarly, a donation made in this way will probably not make me work
92       on this software much more, unless I get so many donations that I can
93       consider working on free software full time (let's all have a chuckle
94       at that together).
95
96       To donate, log into PayPal and send money to autarch@urth.org, or use
97       the button at <http://www.urth.org/~autarch/fs-donation.html>.
98

AUTHOR

100       Dave Rolsky <autarch@urth.org>
101

CONTRIBUTORS

103       •   Andrew Rodland <andrew@cleverdomain.org>
104
105       •   Karen Etheridge <ether@cpan.org>
106
107       •   Rafael Kitover <rkitover@cpan.org>
108
109       •   Robert Buels <rmb32@cornell.edu>
110
111       •   Shawn M Moore <sartak@gmail.com>
112
114       This software is Copyright (c) 2016 by Dave Rolsky.
115
116       This is free software, licensed under:
117
118         The Artistic License 2.0 (GPL Compatible)
119
120
121
122perl v5.34.0                      2022-01-21         MooseX::ClassAttribute(3)
Impressum