.\" Automatically generated by Pod::Man 2.28 (Pod::Simple 3.28) .\" .\" 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 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. .\" .\" 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 .\" .\" 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::Has::Sugar 3pm" .TH MooseX::Has::Sugar 3pm "2014-08-16" "perl v5.20.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::Has::Sugar \- Sugar Syntax for moose 'has' fields .SH "VERSION" .IX Header "VERSION" version 1.000004 .SH "SYNOPSIS" .IX Header "SYNOPSIS" Moose \f(CW\*(C`has\*(C'\fR syntax is generally fine, but sometimes one gets bothered with the constant typing of string quotes for things. The MooseX::Types module exists and in many ways reduces the need for constant string creation. .SS "Primary Benefits at a Glance" .IX Subsection "Primary Benefits at a Glance" \fIReduced Typing in \f(CI\*(C`has\*(C'\fI declarations.\fR .IX Subsection "Reduced Typing in has declarations." .PP The constant need to type \f(CW\*(C`=>\*(C'\fR and \f(CW\*(Aq\*(Aq\fR is fine for one-off cases, but the instant you have more than about 4 attributes it starts to get annoying. .PP \fIMore compact declarations.\fR .IX Subsection "More compact declarations." .PP Reduces much of the redundant typing in most cases, which makes your life easier, and makes it take up less visual space, which makes it faster to read. .PP \fINo String Worries\fR .IX Subsection "No String Worries" .PP Strings are often problematic, due to white-space etc. Noted that if you do happen to mess them up, Moose should at \fIleast\fR warn you that you've done something daft. Using this alleviates that worry. .SS "Before this Module." .IX Subsection "Before this Module." \fIClassical Moose\fR .IX Subsection "Classical Moose" .PP .Vb 5 \& has foo => ( \& isa => \*(AqStr\*(Aq, \& is => \*(Aqro\*(Aq, \& required => 1, \& ); \& \& has bar => ( \& isa => \*(AqStr\*(Aq, \& is => \*(Aqrw\*(Aq \& lazy_build => 1, \& ); .Ve .PP \fILazy Evil way to do it:\fR .IX Subsection "Lazy Evil way to do it:" .PP \&\fB\s-1PLEASE DO NOT DO THIS\s0\fR .PP .Vb 2 \& has qw( foo isa Str is ro required 1 ); \& has qw( bar isa Str is rw lazy_build 1 ); .Ve .SS "With this module" .IX Subsection "With this module" ( and with MooseX::Types ) .PP .Vb 2 \& use MooseX::Types::Moose qw( Str ); \& use MooseX::Has::Sugar; \& \& has foo => ( \& isa => Str, \& ro, \& required, \& ); \& has bar => ( \& isa => Str, \& rw, \& lazy_build, \& ); .Ve .PP Or even .PP .Vb 2 \& use MooseX::Types::Moose qw( Str ); \& use MooseX::Has::Sugar; \& \& has foo => ( isa => Str, ro, required, ); \& has bar => ( isa => Str, rw, lazy_build, ); .Ve .SS "Alternative Forms" .IX Subsection "Alternative Forms" \fIBasic \f(CI\*(C`is\*(C'\fI Expansion Only\fR .IX Subsection "Basic is Expansion Only" .PP ( using ::Sugar::Minimal instead ) .PP .Vb 2 \& use MooseX::Types::Moose qw( Str ); \& use MooseX::Has::Sugar::Minimal; \& \& has foo => ( \& isa => Str, \& is => ro, \& required => 1, \& ); \& has bar => ( \& isa => Str, \& is => rw, \& lazy_build => 1, \& ); .Ve .PP \fIAttribute Expansions with Basic Expansions\fR .IX Subsection "Attribute Expansions with Basic Expansions" .PP ( Combining parts of this and ::Sugar::Minimal ) .PP .Vb 3 \& use MooseX::Types::Moose qw( Str ); \& use MooseX::Has::Sugar::Minimal; \& use MooseX::Has::Sugar qw( :attrs ); \& \& has foo => ( \& isa => Str, \& is => ro, \& required, \& ); \& has bar => ( \& isa => Str, \& is => rw, \& lazy_build, \& ); .Ve .SH "EXPORT GROUPS" .IX Header "EXPORT GROUPS" .ie n .SS """:default""" .el .SS "\f(CW:default\fP" .IX Subsection ":default" Since 0.0300, this exports all our syntax, the same as \f(CW\*(C`:attrs\*(C'\fR \f(CW\*(C`:isattrs\*(C'\fR. Primarily because I found you generally want all the sugar, not just part of it. This also gets rid of that nasty exclusion logic. .ie n .SS """:isattrs""" .el .SS "\f(CW:isattrs\fP" .IX Subsection ":isattrs" This exports \f(CW\*(C`ro\*(C'\fR, \f(CW\*(C`rw\*(C'\fR and \f(CW\*(C`bare\*(C'\fR as lists, so they behave as stand-alone attributes like \&\*(L"lazy\*(R" does. .PP .Vb 5 \& has foo => ( \& required, \& isa => \*(AqStr\*(Aq, \& ro, \& ); .Ve .PP \&\fB\s-1NOTE:\s0 This option is incompatible with ::Sugar::Minimal\fR : \*(L"\s-1CONFLICTS\*(R"\s0 .ie n .SS """:attrs""" .el .SS "\f(CW:attrs\fP" .IX Subsection ":attrs" This exports \*(L"lazy\*(R" , \*(L"lazy_build\*(R" and \*(L"required\*(R", \*(L"coerce\*(R", \*(L"weak_ref\*(R" and \*(L"auto_deref\*(R" as subs that assume positive. .PP .Vb 4 \& has foo => ( \& required, \& isa => \*(AqStr\*(Aq, \& ); .Ve .PP \&\fB\s-1NOTE:\s0 This option is incompatible with MooseX::Types and Moose's Type Constraints Module\fR : \*(L"\s-1CONFLICTS\*(R"\s0 .ie n .SS """:is""" .el .SS "\f(CW:is\fP" .IX Subsection ":is" \&\fB\s-1DEPRECATED\s0\fR. See ::Sugar::Minimal for the same functionality .ie n .SS """:allattrs""" .el .SS "\f(CW:allattrs\fP" .IX Subsection ":allattrs" \&\fB\s-1DEPRECATED\s0\fR, just use \*(L":default\*(R" or do .PP .Vb 1 \& use MooseX::Has::Sugar; .Ve .SH "EXPORTED FUNCTIONS" .IX Header "EXPORTED FUNCTIONS" .ie n .SS """bare""" .el .SS "\f(CWbare\fP" .IX Subsection "bare" returns \f(CW\*(C`(\*(Aqis\*(Aq,\*(Aqbare\*(Aq)\*(C'\fR .ie n .SS """ro""" .el .SS "\f(CWro\fP" .IX Subsection "ro" returns \f(CW\*(C`(\*(Aqis\*(Aq,\*(Aqro\*(Aq)\*(C'\fR .ie n .SS """rw""" .el .SS "\f(CWrw\fP" .IX Subsection "rw" returns \f(CW\*(C`(\*(Aqis\*(Aq,\*(Aqrw\*(Aq)\*(C'\fR .ie n .SS """required""" .el .SS "\f(CWrequired\fP" .IX Subsection "required" returns \f(CW\*(C`(\*(Aqrequired\*(Aq,1)\*(C'\fR .ie n .SS """lazy""" .el .SS "\f(CWlazy\fP" .IX Subsection "lazy" returns \f(CW\*(C`(\*(Aqlazy\*(Aq,1)\*(C'\fR .ie n .SS """lazy_build""" .el .SS "\f(CWlazy_build\fP" .IX Subsection "lazy_build" returns \f(CW\*(C`(\*(Aqlazy_build\*(Aq,1)\*(C'\fR .ie n .SS """weak_ref""" .el .SS "\f(CWweak_ref\fP" .IX Subsection "weak_ref" returns \f(CW\*(C`(\*(Aqweak_ref\*(Aq,1)\*(C'\fR .ie n .SS """coerce""" .el .SS "\f(CWcoerce\fP" .IX Subsection "coerce" returns \f(CW\*(C`(\*(Aqcoerce\*(Aq,1)\*(C'\fR .PP \&\fB\s-1WARNING:\s0\fR Conflict with MooseX::Types and Moose::Util::TypeConstraints, see \*(L"\s-1CONFLICTS\*(R"\s0. .ie n .SS """auto_deref""" .el .SS "\f(CWauto_deref\fP" .IX Subsection "auto_deref" returns \f(CW\*(C`(\*(Aqauto_deref\*(Aq,1)\*(C'\fR .SH "CONFLICTS" .IX Header "CONFLICTS" .SS "MooseX::Has::Sugar::Minimal" .IX Subsection "MooseX::Has::Sugar::Minimal" .SS "MooseX::Has::Sugar::Saccharin" .IX Subsection "MooseX::Has::Sugar::Saccharin" This module is not intended to be used in conjunction with ::Sugar::Minimal or ::Sugar::Saccharin .PP We export many of the same symbols and its just not very sensible. .SS "MooseX::Types" .IX Subsection "MooseX::Types" .SS "Moose::Util::TypeConstraints" .IX Subsection "Moose::Util::TypeConstraints" due to exporting the \*(L"coerce\*(R" symbol, using us in the same scope as a call to .PP .Vb 1 \& use MooseX::Types .... .Ve .PP or use Moose::Util::TypeConstraints .PP will result in a symbol collision. .PP We recommend using and creating proper type libraries instead, ( which will absolve you entirely of the need to use MooseX::Types and MooseX::Has::Sugar(::*)? in the same scope ) .SH "AUTHOR" .IX Header "AUTHOR" Kent Fredric .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2014 by Kent Fredric. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.