MooseX::FunctionParametersInfo(3pm) | User Contributed Perl Documentation | MooseX::FunctionParametersInfo(3pm) |
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.
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.
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-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.
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.
2019-01-18 | perl v5.28.1 |