NAME

Pad::Tie::Plugin - base class for method personalities

SYNOPSIS

package Pad::Tie::Plugin::Mine;

sub provides { 'mine' }

sub mine {
  my ($plugin, $ctx, $self, $args) = @_;
  # put some stuff into $ctx
}

DESCRIPTION

Pad::Tie::Plugin is a convenient place to put common method personality functionality.

There's no practical reason that your plugin needs to inherit from Pad::Tie::Plugin, but it should anyway, for the sake of future-proofing.

Your plugin should have two or more methods:

  • provides

    This method should return a list of method personality names handled by this plugin.

  • (your method personality names)

    Each of these methods will be called whenever a new Pad::Tie object is created. It will be called with the plugin (since it is a method) and 3 additional arguments: the context, the invocant, and whatever the argument was in the original method configuration. See Lexical::Persistence for details about the context, Pad::Tie for the others, and "SYNOPSIS" for an example.

METHODS

canon_args

my $args = $plugin->canon_args($args);

Given an arrayref of arrayrefs, each of which represents a method name and possible arguments, return a hashref of method name to lexical variable.

A few special arguments are accepted:

  • -as

    Instead of using the given method name, use this value

(more options will be added as I think of them)

For example, this transformation would be done:

[
  [ 'foo' ],
  [ 'bar' => { -as => 'baz' } ],
],

to

{
  foo => 'foo',
  bar => 'baz',
}

If your plugin doesn't want to take arguments, or doesn't want to handle them as method names, you don't need to use this method, but it is handy to have.

TODO

plugin subclass for variables tied to methods

SEE ALSO

Pad::Tie

1 POD Error

The following errors were encountered while parsing the POD:

Around line 73:

You forgot a '=back' before '=head1'