Skip to content

Commit

Permalink
closes #8; added example usage in EXAMPLE section
Browse files Browse the repository at this point in the history
  • Loading branch information
stevieb9 committed Feb 11, 2018
1 parent c3457d6 commit 3f21186
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -4,6 +4,7 @@ Revision history for Plugin-Simple
- fix missing closing single quote in SYNOPSIS (closes #10)
- remove CONTRIBUTING section in POD (closes #9)
- fix incorrect sub name in POD and warnings (closes #7)
- added example use case in EXAMPLE (closes #8)

0.07 2016-03-28
- fixed a missed croak() if a plugin file can't be found, breaking
Expand Down
45 changes: 45 additions & 0 deletions lib/Plugin/Simple.pm
Expand Up @@ -244,6 +244,51 @@ To use both options, simply separate them with a comma.
None. We simply install a C<plugins()> function within the namespace of the
package that C<use>d us.
=head1 EXAMPLE
This example simply uses a single plugin module with a C<plugin_function()>
function. In the script, we load this file, and check to ensure the plugin does
in fact have that sub available.
We then call the plugins in a loop (even though in this case there's only one),
and send in an argument for the plugin to do work on.
=head2 Script
use warnings;
use strict;
use lib '.';
use Plugin::Simple;
my @plugins = plugins(
'examples/TestPlugin.pm',
can => ['plugin_function']
);
my $plugin_arg = 'Hello!';
for my $plugin (@plugins){
$plugin->plugin_function($plugin_arg);
}
=head2 Plugin Module
package TestPlugin;
sub plugin_function {
shift; # throw away class/obj
my ($str) = @_;
print "in " . __PACKAGE__ . ", arg is: $str\n";
}
1;
=head2 Output
in TestPlugin, arg is: Hello!
=head1 AUTHOR
Steve Bertrand, C<< <steveb at cpan.org> >>
Expand Down

0 comments on commit 3f21186

Please sign in to comment.