RT 5.0.1 Documentation

RT::Shredder::Plugin

Go to latest version →

NAME

RT::Shredder::Plugin - interface to access shredder plugins

SYNOPSIS

  use RT::Shredder::Plugin;

  # get list of the plugins
  my %plugins = RT::Shredder::Plugin->List;

  # load plugin by name
  my $plugin = RT::Shredder::Plugin->new;
  my( $status, $msg ) = $plugin->LoadByName( 'Tickets' );
  unless( $status ) {
      print STDERR "Couldn't load plugin 'Tickets': $msg\n";
      exit(1);
  }

  # load plugin by preformatted string
  my $plugin = RT::Shredder::Plugin->new;
  my( $status, $msg ) = $plugin->LoadByString( 'Tickets=status,deleted' );
  unless( $status ) {
      print STDERR "Couldn't load plugin: $msg\n";
      exit(1);
  }

METHODS

new

Object constructor, returns new object. Takes optional hash as arguments, it's not required and this class doesn't use it, but plugins could define some arguments and can handle them after your've load it.

List

Returns hash with names of the available plugins as keys and path to library files as values. Method has no arguments. Can be used as class method too.

Takes optional argument type and leaves in the result hash only plugins of that type.

LoadByName

Takes name of the plugin as first argument, loads plugin, creates new plugin object and reblesses self into plugin if all steps were successfuly finished, then you don't need to create new object for the plugin.

Other arguments are sent to the constructor of the plugin (method new.)

Returns $status and $message. On errors status is false value.

In scalar context, returns $status only.

LoadByString

Takes formatted string as first argument and which is used to load plugin. The format of the string is

  <plugin name>[=<arg>,<val>[;<arg>,<val>]...]

exactly like in the rt-shredder script. All other arguments are sent to the plugins constructor.

Method does the same things as LoadByName, but also checks if the plugin supports arguments and values are correct, so you can Run specified plugin immediatly.

Returns list with $status and $message. On errors status is false.

Rebless

Instance method that takes one object as argument and rebless the current object into into class of the argument and copy data of the former. Returns nothing.

Method is used by Load* methods to automaticaly rebless RT::Shredder::Plugin object into class of the loaded plugin.

← Back to index