summaryrefslogtreecommitdiff
path: root/lib/Net/HTTP/Console/Role/Plugins.pm
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-06-08 15:31:32 +0200
committerfranck cuny <franck@lumberjaph.net>2010-06-08 15:31:32 +0200
commite71a441a81f6f1d7e61fdb3c07e2f48ee10ba97d (patch)
tree082cc92aa529f373dec8ac497929f57068660afe /lib/Net/HTTP/Console/Role/Plugins.pm
parentswitch to MX::Declare; rename some roles and dispatcher (diff)
downloadnet-http-console-e71a441a81f6f1d7e61fdb3c07e2f48ee10ba97d.tar.gz
move code to appropriate role
Diffstat (limited to '')
-rw-r--r--lib/Net/HTTP/Console/Role/Plugins.pm13
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/Net/HTTP/Console/Role/Plugins.pm b/lib/Net/HTTP/Console/Role/Plugins.pm
index a3136f2..d7bf7b5 100644
--- a/lib/Net/HTTP/Console/Role/Plugins.pm
+++ b/lib/Net/HTTP/Console/Role/Plugins.pm
@@ -4,6 +4,8 @@ use MooseX::Declare;
role Net::HTTP::Console::Role::Plugins {
+ use Try::Tiny;
+
has dispatchers => (
is => 'rw',
isa => 'ArrayRef[Str]',
@@ -33,6 +35,17 @@ role Net::HTTP::Console::Role::Plugins {
\@p;
},
);
+
+ method dispatch ($input) {
+ my $result;
+ try {
+ foreach ($self->all_plugins) {
+ last if ($result = $_->dispatch($input));
+ }
+ }catch{
+ print "[ERROR]: ".$_;
+ };
+ }
}
1;