.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.42) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "MooseX::ClassAttribute 3pm" .TH MooseX::ClassAttribute 3pm "2022-10-16" "perl v5.34.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" MooseX::ClassAttribute \- Declare class attributes Moose\-style .SH "VERSION" .IX Header "VERSION" version 0.29 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package My::Class; \& \& use Moose; \& use MooseX::ClassAttribute; \& \& class_has \*(AqCache\*(Aq => \& ( is => \*(Aqrw\*(Aq, \& isa => \*(AqHashRef\*(Aq, \& default => sub { {} }, \& ); \& \& _\|_PACKAGE_\|_\->meta()\->make_immutable(); \& \& no Moose; \& no MooseX::ClassAttribute; \& \& # then later ... \& \& My::Class\->Cache()\->{thing} = ...; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module allows you to declare class attributes in exactly the same way as object attributes, using \f(CW\*(C`class_has()\*(C'\fR instead of \f(CW\*(C`has()\*(C'\fR. .PP You can use any feature of Moose's attribute declarations, including overriding a parent's attributes, delegation (\f(CW\*(C`handles\*(C'\fR), attribute traits, etc. All features should just work. The one exception is the \*(L"required\*(R" flag, which is not allowed for class attributes. .PP The accessor methods for class attribute may be called on the class directly, or on objects of that class. Passing a class attribute to the constructor will not set that attribute. .SH "FUNCTIONS" .IX Header "FUNCTIONS" This class exports one function when you use it, \f(CW\*(C`class_has()\*(C'\fR. This works exactly like Moose's \f(CW\*(C`has()\*(C'\fR, but it declares class attributes. .PP One little nit is that if you include \f(CW\*(C`no Moose\*(C'\fR in your class, you won't remove the \f(CW\*(C`class_has()\*(C'\fR function. To do that you must include \f(CW\*(C`no MooseX::ClassAttribute\*(C'\fR as well. Or you can just use namespace::autoclean instead. .SS "Implementation and Immutability" .IX Subsection "Implementation and Immutability" This module will add a role to your class's metaclass, See MooseX::ClassAttribute::Trait::Class for details. This role provides introspection methods for class attributes. .PP Class attributes themselves do the MooseX::ClassAttribute::Trait::Attribute role. .SS "Cooperation with Metaclasses and Traits" .IX Subsection "Cooperation with Metaclasses and Traits" This module should work with most attribute metaclasses and traits, but it's possible that conflicts could occur. This module has been tested to work with Moose's native traits. .SS "Class Attributes in Roles" .IX Subsection "Class Attributes in Roles" You can add a class attribute to a role. When that role is applied to a class, the class will have the relevant class attributes added. Note that attribute defaults will be calculated when the class attribute is composed into the class. .SH "SUPPORT" .IX Header "SUPPORT" Bugs may be submitted through the \s-1RT\s0 bug tracker (or bug\-moosex\-classattribute@rt.cpan.org ). .PP I am also usually active on \s-1IRC\s0 as 'drolsky' on \f(CW\*(C`irc://irc.perl.org\*(C'\fR. .SH "DONATIONS" .IX Header "DONATIONS" If you'd like to thank me for the work I've done on this module, please consider making a \*(L"donation\*(R" to me via PayPal. I spend a lot of free time creating free software, and would appreciate any support you'd care to offer. .PP Please note that \fBI am not suggesting that you must do this\fR in order for me to continue working on this particular software. I will continue to do so, inasmuch as I have in the past, for as long as it interests me. .PP Similarly, a donation made in this way will probably not make me work on this software much more, unless I get so many donations that I can consider working on free software full time (let's all have a chuckle at that together). .PP To donate, log into PayPal and send money to autarch@urth.org, or use the button at . .SH "AUTHOR" .IX Header "AUTHOR" Dave Rolsky .SH "CONTRIBUTORS" .IX Header "CONTRIBUTORS" .IP "\(bu" 4 Andrew Rodland .IP "\(bu" 4 Karen Etheridge .IP "\(bu" 4 Rafael Kitover .IP "\(bu" 4 Robert Buels .IP "\(bu" 4 Shawn M Moore .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is Copyright (c) 2016 by Dave Rolsky. .PP This is free software, licensed under: .PP .Vb 1 \& The Artistic License 2.0 (GPL Compatible) .Ve