MooseX::FunctionParametersInfo(3pm)

MooseX::FunctionParametersInfo3pm

Make function::parameters::info() data available within the meta object protocol

Usage

   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

Overview

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.

Methods

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.

"declaration_keyword"

Returns the name of the keyword used to declare the method; e.g. "sub" or "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.

"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.

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.

Releases

2 releases since Debian 9 (Stretch); the text changed 1 time.

  1. 9
  2. 10

Bugs

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

Author

Toby Inkster <[email protected]>.

From libmoops-perl 0.036-1 in Debian 10 (Buster). Parsed by carta from the page's man source.