Hans Dieter Pearcey > Pad-Tie > Pad::Tie::Plugin

Download:
Pad-Tie-0.006.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
Report a bug
Source  

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:

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:

(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