MooseX::FunctionParametersInfo - make Function::Parameters::info() data available within the meta object protocol
package Foo { use Function::Parameters; use Moose; use MooseX::FunctionParametersInfo; method bar (Str $x, Int $y) { ...; } } my $method = Class::MOP::class_of('Foo')->get_method('bar'); printf("%s %s\n", $_->type, $_->name) for $method->positional_parameters; __END__ Str $x Int $y
Function::Parameters provides declarative sugar for processing arguments to subs, and provides a small API to query the declarations.
Moose provides a comprehensive introspection API for Perl classes.
MooseX::FunctionParametersInfo marries them together, injecting information from Function::Parameters into Moose's meta objects.
MooseX::FunctionParametersInfo is currently distributed as part of Moops, but is fairly independent of the rest of it, and may be spun off as a separate release in the future.
MooseX::FunctionParametersInfo adds the following methods to the Moose::Meta::Method objects for your class. If your method is wrapped, it is the info from the original (wrapped) method that is reported; not the info from the wrapper. If your method was not declared via Function::Parameters (e.g. it was declared using the Perl built-in sub keyword) then we make a best guess.
sub
Methods that return parameters, return Function::Parameters::Parameter objects, which have name and type methods. The type (if any) will be a blessed type constraint object, such as a Moose::Meta::TypeConstraint or Type::Tiny object.
name
type
declaration_keyword
Returns the name of the keyword used to declare the method; e.g. "sub" or "method".
"sub"
"method"
slurpy_parameter
The array parameter into which additional arguments will be slurped, or undef.
invocant_parameter
The parameter which is the method's invocant (typically, $self or $class), or undef.
$self
$class
positional_required_parameters
positional_optional_parameters
named_required_parameters
named_optional_parameters
Returns the appropriate parameters as a list.
positional_parameters
named_parameters
A list of the required parameters followed by optional parameters.
minimum_parameters
maximum_parameters
The minimum and maximum number of parameters the method can take.
Please report any bugs to http://rt.cpan.org/Dist/Display.html?Queue=Moops.
Moose, Function::Parameters, Function::Parameters::Info.
Moops.
Toby Inkster <tobyink@cpan.org>.
This software is copyright (c) 2013 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.
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.
To install Moops, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Moops
CPAN shell
perl -MCPAN -e shell install Moops
For more information on module installation, please visit the detailed CPAN module installation guide.