summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2013-08-07 20:26:51 -0400
committerJesse Luehrs <doy@tozt.net>2013-09-03 16:50:15 -0400
commit7df1338f58d10c01cf8f742832b57b2736dbf301 (patch)
tree9998f91a24888e8b81e9079ea35a266ab7259820
parent22adfca628dd4c9933c95d2ae619f98d78d5da46 (diff)
downloadreply-7df1338f58d10c01cf8f742832b57b2736dbf301.tar.gz
reply-7df1338f58d10c01cf8f742832b57b2736dbf301.zip
convert the plugin base class
-rw-r--r--lib/Reply/Plugin.pm31
1 files changed, 11 insertions, 20 deletions
diff --git a/lib/Reply/Plugin.pm b/lib/Reply/Plugin.pm
index 2c06e8e..d9d7cb3 100644
--- a/lib/Reply/Plugin.pm
+++ b/lib/Reply/Plugin.pm
@@ -1,8 +1,10 @@
-package Reply::Plugin;
+package main;
use strict;
use warnings;
# ABSTRACT: base class for Reply plugins
+use mop;
+
use Reply::Util 'methods';
=head1 SYNOPSIS
@@ -168,16 +170,8 @@ messages you want to communicate.
=cut
-sub new {
- my $class = shift;
- my (%opts) = @_;
-
- die "publisher is required" unless $opts{publisher};
-
- return bless {
- publisher => $opts{publisher},
- }, $class;
-}
+class Reply::Plugin is sealed, instance('HASH') {
+ has $publisher = die "publisher is required";
=method publish ($name, @args)
@@ -187,11 +181,9 @@ the parameters. Returns a list of everything that each plugin responded with.
=cut
-sub publish {
- my $self = shift;
-
- $self->{publisher}->(@_);
-}
+ method publish ($method, @args) {
+ $publisher->($method, @args);
+ }
=method commands
@@ -202,10 +194,9 @@ session.
=cut
-sub commands {
- my $self = shift;
-
- return map { s/^command_//; $_ } grep { /^command_/ } methods($self);
+ method commands {
+ map { s/^command_//; $_ } grep { /^command_/ } methods($self);
+ }
}
=for Pod::Coverage