.\" Automatically generated by Pod::Man 2.25 (Pod::Simple 3.16) .\" .\" 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" '' '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 turned on, 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. .ie \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . nr % 0 . rr F .\} .el \{\ . de IX .. .\} .\" .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2). .\" Fear. Run. Save yourself. No user-serviceable parts. . \" fudge factors for nroff and troff .if n \{\ . ds #H 0 . ds #V .8m . ds #F .3m . ds #[ \f1 . ds #] \fP .\} .if t \{\ . ds #H ((1u-(\\\\n(.fu%2u))*.13m) . ds #V .6m . ds #F 0 . ds #[ \& . ds #] \& .\} . \" simple accents for nroff and troff .if n \{\ . ds ' \& . ds ` \& . ds ^ \& . ds , \& . ds ~ ~ . ds / .\} .if t \{\ . ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u" . ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u' . ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u' . ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u' . ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u' . ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u' .\} . \" troff and (daisy-wheel) nroff accents .ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V' .ds 8 \h'\*(#H'\(*b\h'-\*(#H' .ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#] .ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H' .ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u' .ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#] .ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#] .ds ae a\h'-(\w'a'u*4/10)'e .ds Ae A\h'-(\w'A'u*4/10)'E . \" corrections for vroff .if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u' .if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u' . \" for low resolution devices (crt and lpr) .if \n(.H>23 .if \n(.V>19 \ \{\ . ds : e . ds 8 ss . ds o a . ds d- d\h'-1'\(ga . ds D- D\h'-1'\(hy . ds th \o'bp' . ds Th \o'LP' . ds ae ae . ds Ae AE .\} .rm #[ #] #H #V #F C .\" ======================================================================== .\" .IX Title "MooseX::AttributeShortcuts 3pm" .TH MooseX::AttributeShortcuts 3pm "2012-04-07" "perl v5.14.2" "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::AttributeShortcuts \- Shorthand for common attribute options .SH "VERSION" .IX Header "VERSION" This document describes version 0.010 of MooseX::AttributeShortcuts \- released April 06, 2012 as part of MooseX-AttributeShortcuts. .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& package Some::Class; \& \& use Moose; \& use MooseX::AttributeShortcuts; \& \& # same as: \& # is => \*(Aqro\*(Aq, lazy => 1, builder => \*(Aq_build_foo\*(Aq \& has foo => (is => \*(Aqlazy\*(Aq); \& \& # same as: is => \*(Aqro\*(Aq, writer => \*(Aq_set_foo\*(Aq \& has foo => (is => \*(Aqrwp\*(Aq); \& \& # same as: is => \*(Aqro\*(Aq, builder => \*(Aq_build_bar\*(Aq \& has bar => (is => \*(Aqro\*(Aq, builder => 1); \& \& # same as: is => \*(Aqro\*(Aq, clearer => \*(Aqclear_bar\*(Aq \& has bar => (is => \*(Aqro\*(Aq, clearer => 1); \& \& # same as: is => \*(Aqro\*(Aq, predicate => \*(Aqhas_bar\*(Aq \& has bar => (is => \*(Aqro\*(Aq, predicate => 1); \& \& # works as you\*(Aqd expect for "private": predicate => \*(Aq_has_bar\*(Aq \& has _bar => (is => \*(Aqro\*(Aq, predicate => 1); \& \& # extending? Use the "Shortcuts" trait alias \& extends \*(AqSome::OtherClass\*(Aq; \& has \*(Aq+bar\*(Aq => (traits => [Shortcuts], builder => 1, ...); \& \& # or... \& package Some::Other::Class; \& \& use Moose; \& use MooseX::AttributeShortcuts \-writer_prefix => \*(Aq_\*(Aq; \& \& # same as: is => \*(Aqro\*(Aq, writer => \*(Aq_foo\*(Aq \& has foo => (is => \*(Aqrwp\*(Aq); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" Ever find yourself repeatedly specifying writers and builders, because there's no good shortcut to specifying them? Sometimes you want an attribute to have a read-only public interface, but a private writer. And wouldn't it be easier to just say \*(L"builder => 1\*(R" and have the attribute construct the canonical \&\*(L"_build_$name\*(R" builder name for you? .PP This package causes an attribute trait to be applied to all attributes defined to the using class. This trait extends the attribute option processing to handle the above variations. .SH "USAGE" .IX Header "USAGE" This package automatically applies an attribute metaclass trait. Unless you want to change the defaults, you can ignore the talk about \*(L"prefixes\*(R" below. .SH "EXTENDING A CLASS" .IX Header "EXTENDING A CLASS" If you're extending a class and trying to extend its attributes as well, you'll find out that the trait is only applied to attributes defined locally in the class. This package exports a trait shortcut function \*(L"Shortcuts\*(R" that will help you apply this to the extended attribute: .PP .Vb 1 \& has \*(Aq+something\*(Aq => (traits => [Shortcuts], ...); .Ve .SH "PREFIXES" .IX Header "PREFIXES" We accept two parameters on the use of this module; they impact how builders and writers are named. .SS "\-writer_prefix" .IX Subsection "-writer_prefix" .Vb 1 \& use MooseX::::AttributeShortcuts \-writer_prefix => \*(Aqprefix\*(Aq; .Ve .PP The default writer prefix is '_set_'. If you'd prefer it to be something else (say, '_'), this is where you'd do that. .SS "\-builder_prefix" .IX Subsection "-builder_prefix" .Vb 1 \& use MooseX::::AttributeShortcuts \-builder_prefix => \*(Aqprefix\*(Aq; .Ve .PP The default builder prefix is '_build_', as this is what lazy_build does, and what people in general recognize as build methods. .SH "NEW ATTRIBUTE OPTIONS" .IX Header "NEW ATTRIBUTE OPTIONS" Unless specified here, all options defined by Moose::Meta::Attribute and Class::MOP::Attribute remain unchanged. .PP Want to see additional options? Ask, or better yet, fork on GitHub and send a pull request. .PP For the following, \*(L"$name\*(R" should be read as the attribute name; and the various prefixes should be read using the defaults. .SS "is => 'rwp'" .IX Subsection "is => 'rwp'" Specifying \f(CW\*(C`is => \*(Aqrwp\*(Aq\*(C'\fR will cause the following options to be set: .PP .Vb 2 \& is => \*(Aqro\*(Aq \& writer => "_set_$name" .Ve .SS "is => 'lazy'" .IX Subsection "is => 'lazy'" Specifying \f(CW\*(C`is => \*(Aqlazy\*(Aq\*(C'\fR will cause the following options to be set: .PP .Vb 3 \& is => \*(Aqro\*(Aq \& builder => "_build_$name" \& lazy => 1 .Ve .PP \&\fB\s-1NOTE:\s0\fR Since 0.009 we no longer set \f(CW\*(C`init_arg => undef\*(C'\fR if no \f(CW\*(C`init_arg\*(C'\fR is explicitly provided. This is a change made in parallel with Moo, based on a large number of people surprised that lazy also made one's \f(CW\*(C`init_def\*(C'\fR undefined. .SS "is => 'lazy', default => ..." .IX Subsection "is => 'lazy', default => ..." Specifying \f(CW\*(C`is => \*(Aqlazy\*(Aq\*(C'\fR and a default will cause the following options to be set: .PP .Vb 3 \& is => \*(Aqro\*(Aq \& lazy => 1 \& default => ... # as provided .Ve .PP That is, if you specify \f(CW\*(C`is => \*(Aqlazy\*(Aq\*(C'\fR and also provide a \f(CW\*(C`default\*(C'\fR, then we won't try to set a builder, as well. .SS "builder => 1" .IX Subsection "builder => 1" Specifying \f(CW\*(C`builder => 1\*(C'\fR will cause the following options to be set: .PP .Vb 1 \& builder => "_build_$name" .Ve .SS "clearer => 1" .IX Subsection "clearer => 1" Specifying \f(CW\*(C`clearer => 1\*(C'\fR will cause the following options to be set: .PP .Vb 1 \& clearer => "clear_$name" .Ve .PP or, if your attribute name begins with an underscore: .PP .Vb 1 \& clearer => "_clear$name" .Ve .PP (that is, an attribute named \*(L"_foo\*(R" would get \*(L"_clear_foo\*(R") .SS "predicate => 1" .IX Subsection "predicate => 1" Specifying \f(CW\*(C`predicate => 1\*(C'\fR will cause the following options to be set: .PP .Vb 1 \& predicate => "has_$name" .Ve .PP or, if your attribute name begins with an underscore: .PP .Vb 1 \& predicate => "_has$name" .Ve .PP (that is, an attribute named \*(L"_foo\*(R" would get \*(L"_has_foo\*(R") .SS "trigger => 1" .IX Subsection "trigger => 1" Specifying \f(CW\*(C`trigger => 1\*(C'\fR will cause the attribute to be created with a trigger that calls a named method in the class with the options passed to the trigger. By default, the method name the trigger calls is the name of the attribute prefixed with \*(L"_trigger_\*(R". .PP e.g., for an attribute named \*(L"foo\*(R" this would be equivalent to: .PP .Vb 1 \& trigger => sub { shift\->_trigger_foo(@_) } .Ve .PP For an attribute named \*(L"_foo\*(R": .PP .Vb 1 \& trigger => sub { shift\->_trigger_\|_foo(@_) } .Ve .PP This naming scheme, in which the trigger is always private, is the same as the builder naming scheme (just with a different prefix). .SH "SOURCE" .IX Header "SOURCE" The development version is on github at http://github.com/RsrchBoy/moosex\-attributeshortcuts and may be cloned from git://github.com/RsrchBoy/moosex\-attributeshortcuts.git .SH "BUGS" .IX Header "BUGS" Please report any bugs or feature requests on the bugtracker website https://github.com/RsrchBoy/moosex\-attributeshortcuts/issues .PP When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature. .SH "AUTHOR" .IX Header "AUTHOR" Chris Weyl .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is Copyright (c) 2011 by Chris Weyl. .PP This is free software, licensed under: .PP .Vb 1 \& The GNU Lesser General Public License, Version 2.1, February 1999 .Ve