/usr/share/doc/libclass-pluggable-perl/README is in libclass-pluggable-perl 0.022-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 | NAME
Class::Pluggable - Simple pluggable class.
SYNOPSIS
use Class::Pluggable;
use base qw(Class::Pluggable);
# Some::Plugin::Module has sub routin called newAction
addPlugin("Some::Plugin::Module");
newAction(); # Plugged action.
DESCRIPTION
This class makes your class (sub class of Class::Pluggable) pluggable.
In this documentatin, the word "pluggable" has two meanings.
One is just simply adding new method to your pluggable classs from other
plugin modules. So, after you plugged some modules to your class, you
can use there method exactly same as your own object method.
You can see this kind of plugin mechanism in CGI::Application and
CGI::Application::Plugin::Session.
There are one thing that Plugin developer have to know. The plugin
module MUST have @EXPORT_AS_PLUGIN to use this pluggable mechanism. This
works almost same as @EXPORT. But the methods in the @EXPORT_AS_PLUGIN
wouldn't be exported to your package. But it would be exported to the
subclass of Class::Pluggable (only when you call addPlugin()).
And the another meaning of "pluggable" is so called hook-mechanism. For
example, if you want to allow to other modules to do something before
and/or after some action. You can do like this:
$self->executePluginMethod($_, "before_action")
foreach $self->getPlugins();
## do some your own action here.
$self->executePluginMethod($_, "after_action")
foreach $self->getPlugins();
METHODS
Here are all methods of Class::Pluggable.
addPlugin
YourClass->addPlugin($pluginName)
This will add new plugin to your class. What you added to here would
be returned by getPlugins() method.
getPlugins
@plugins = YourClass->getPlugins();
It will return all of plugin names that are already added to
YouClass.
executePluginMethod
$result = YourClass->executePluginMethod("SomePlugin", "someMethod");
This will execute the method someMethod of SomePlugin.
executeAllPluginMethod
YourClass->executeAllPluginMethod("someMethod");
This will execute the method someMethod of all plugin we have. This
is almost same as following code.
$self->executePluginMethod($_, "someMethod")
foreach $self->getPlugins();
The difference is executeAllPluginMethod can't return any values.
But executePluginMethod can.
addHook
YourClass->addHook("pre-init", "pre_init");
This will add new hook to your class. Whenever runHook("pre-init")
has called, the method pre_init of all plugins which we have will be
executed.
runHook
YourClass->runHook("pre-init");
This will execute the hook-method of all plugins which we have.
deleteHook
YourClass->deleteHook("pre-init");
This will delete the hook from YourClass. After calling this method,
you cannot call runHook("pre-init"). If you do, it will die
immediately.
SEE ALSO
...
AUTHOR
Ken Takeshige, <ken.takeshige@gmail.com>
COPYRIGHT AND LICENSE
Copyright (C) 2006 by Ken Takeshige
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.6
or, at your option, any later version of Perl 5 you may have
available.
|