Kavorka::Parameter(3) a single parameter in a function signature

DESCRIPTION

Kavorka::Parameter is a class where each instance represents a parameter in a function signature. This class is used to help parse the function signature, and also to inject Perl code into the final function.

Instances of this class are also returned by Kavorka's function introspection API.

Introspection API

A parameter instance has the following methods:
"ID"
An opaque numeric identifier for this parameter.
"package"
Returns the package name the parameter was declared in.
"type"
A Type::Tiny object representing the type constraint for the parameter, or undef.
"name"
The name of the variable associated with this parameter, including its sigil.
"constraints"
An arrayref of additional constraints upon the value. These are given as coderefs.
"named"
A boolean indicating whether this is a named parameter.
"named_names"
An arrayref of names for this named parameter.
"position"
The position for a positional parameter.
"default"
A coderef supplying the default value for this parameter.
"default_when"
The string ``='', ``//='' or ``||=''.
"traits"
A hashref, where the keys represent names of parameter traits, and the values are booleans.
"sigil"
The sigil of the variable for this parameter.
"kind"
Returns ``our'' for package variables; ``global'' for namespace-qualified package variables (i.e. containing ``::''); ``magic'' for $_ and escape char variables like "${^HELLO}"; ``my'' otherwise.
"readonly", "ro"
A boolean indicating whether this variable will be read-only.
"rw"
A boolean indicating whether this variable will be read-write.
"locked"
A boolean indicating whether this variable is a locked hash(ref).
"alias"
A boolean indicating whether this variable will be an alias.
"copy"
A boolean indicating whether this variable will be a copy (non-alias).
"slurpy"
A boolean indicating whether this variable is slurpy.
"optional"
A boolean indicating whether this variable is optional.
"invocant"
A boolean indicating whether this variable is an invocant.
"coerce"
A boolean indicating whether this variable should coerce.

Other Methods

"parse"
An internal method used to parse a parameter. Only makes sense to use within a Parse::Keyword parser.
"injection"
The string of Perl code to inject for this parameter.
"sanity_check"
Tests that the parameter is sane. (For example it would not be sane to have an invocant that is an optional parameter.)

BUGS

Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Kavorka>.

AUTHOR

Toby Inkster <[email protected]>.

COPYRIGHT AND LICENCE

This software is copyright (c) 2013-2014 by Toby Inkster.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

DISCLAIMER OF WARRANTIES

THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.