.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" 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 .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "MooseX::Has::Options 3pm" .TH MooseX::Has::Options 3pm "2018-05-06" "perl v5.26.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::Has::Options \- Succinct options for Moose .SH "VERSION" .IX Header "VERSION" version 0.003 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use Moose; \& use MooseX::Has::Options; \& \& has \*(Aqsome_attribute\*(Aq => ( \& qw(:ro :required), \& isa => \*(AqStr\*(Aq, \& ... \& ); \& \& has \*(Aqanother_attribute\*(Aq => ( \& qw(:ro :lazy_build), \& isa => \*(AqStr\*(Aq, \& ... \& ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module provides a succinct syntax for declaring options for Moose attributes. .SH "USAGE" .IX Header "USAGE" .SS "Declaring options" .IX Subsection "Declaring options" \&\f(CW\*(C`MooseX::Has::Params\*(C'\fR works by checking the arguments to \f(CW\*(C`has\*(C'\fR for strings that look like options, i.e. alphanumeric strings preceded by a colon, and replaces them with a hash whose keys are the names of the options (sans the colon) and the values are \f(CW1\fR's. Thus, .PP .Vb 1 \& has \*(Aqsome_attribute\*(Aq, \*(Aq:required\*(Aq; .Ve .PP becomes: .PP .Vb 1 \& has \*(Aqsome_attribute\*(Aq, required => 1; .Ve .PP Options must come in the beginning of the argument list. MooseX::Has::Options will stop searching for options after the first alphanumeric string that does not start with a colon. .PP The default behaviour can be customised per attribute. For example, here is how \f(CW\*(C`ro\*(C'\fR, \f(CW\*(C`rw\*(C'\fR and \f(CW\*(C`bare\*(C'\fR work: .PP .Vb 1 \& has \*(Aqsome_attribute\*(Aq, \*(Aq:ro\*(Aq; .Ve .PP becomes: .PP .Vb 1 \& has \*(Aqsome_attribute\*(Aq, is => \*(Aqro\*(Aq; .Ve .PP See below for details. .SS "Handlers" .IX Subsection "Handlers" \&\f(CW\*(C`MooseX::Has::Options\*(C'\fR allows you to expand specific 'shortcut' arguments to arbitrary values via the handler interface. A 'handler' is a module in the MooseX::Has::Options::Handler namespace that provides a \f(CW\*(C`handler\*(C'\fR function. The handler function should return a hash whose keys are shortcut names, and the values are hashrefs with the values that the respective shortcuts should be expanded to. In order to enable the shortcuts supplied by a given handler you need to add it in the import statement: .PP .Vb 1 \& use MooseX::Has::Options qw(NativeTypes); \& \& has \*(Aqsome_attribute\*(Aq, qw(:ro :hash), default => sub {{ foo => bar }}; .Ve .PP The following handlers ship with the default distribution: .IP "\(bu" 4 MooseX::Has::Options::Handler::Accessors (included by default when you import this module) .IP "\(bu" 4 MooseX::Has::Options::Handler::NativeTypes .IP "\(bu" 4 MooseX::Has::Options::Handler::NoInit .SH "IMPLEMENTATION DETAILS" .IX Header "IMPLEMENTATION DETAILS" \&\f(CW\*(C`MooseX::Has::Options\*(C'\fR hijacks the \f(CW\*(C`has\*(C'\fR function imported by Moose and replaces it with one that understands the options syntax described above. This is not an optimal solution, but the current implementation of \f(CW\*(C`Moose::Meta::Attribute\*(C'\fR prevents this functionality from being provided as a meta trait. .SH "DEPRECATED BEHAVIOUR" .IX Header "DEPRECATED BEHAVIOUR" Previous versions of \f(CW\*(C`MooseX::Has::Params\*(C'\fR allowed you to specify during import the name of the function too hook into, like so: .PP .Vb 2 \& use HTML::FormHandler::Moose; \& use MooseX::Has::Options qw(has_field); \& \& has_field \*(Aqname\*(Aq => ( \& qw(:required), \& type => \*(AqText\*(Aq, \& ); .Ve .PP This behaviour is deprecated as of version 0.003 as this syntax is now used for specifying handlers. If you need to hook into a different function see the implementation of \f(CW\*(C`MooseX::Has::Options::import()\*(C'\fR and \f(CW\*(C`MooseX::Has::Options::import_into()\*(C'\fR. .SH "SEE ALSO" .IX Header "SEE ALSO" .IP "\(bu" 4 MooseX::Has::Sugar .SH "AUTHOR" .IX Header "AUTHOR" Peter Shangov .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2012 by Peter Shangov. .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.