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.16
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       There is also a MooseX::ClassAttribute::Meta::Method::Accessor which
63       provides part of the inlining implementation for class attributes.
64
65   Cooperation with Metaclasses and Traits
66       This module should work with most attribute metaclasses and traits, but
67       it's possible that conflicts could occur. This module has been tested
68       to work with Moose's native traits.
69
70   Class Attributes in Roles
71       You can add a class attribute to a role. When that role is applied to a
72       class, the class will have the relevant class attributes added. Note
73       that attribute defaults will be calculated when the class attribute is
74       composed into the class.
75

DONATIONS

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

BUGS

96       Please report any bugs or feature requests to
97       "bug-moosex-classattribute@rt.cpan.org", or through the web interface
98       at <http://rt.cpan.org>.  I will be notified, and then you'll
99       automatically be notified of progress on your bug as I make changes.
100

AUTHOR

102         Dave Rolsky <autarch@urth.org>
103
105       This software is Copyright (c) 2010 by Dave Rolsky.
106
107       This is free software, licensed under:
108
109         The Artistic License 2.0
110
111
112
113perl v5.12.2                      2010-07-15         MooseX::ClassAttribute(3)
Impressum