summaryrefslogtreecommitdiff
path: root/lib/Net/HTTP/Console/Role/Plugins.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Net/HTTP/Console/Role/Plugins.pm')
-rw-r--r--lib/Net/HTTP/Console/Role/Plugins.pm38
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/Net/HTTP/Console/Role/Plugins.pm b/lib/Net/HTTP/Console/Role/Plugins.pm
new file mode 100644
index 0000000..a3136f2
--- /dev/null
+++ b/lib/Net/HTTP/Console/Role/Plugins.pm
@@ -0,0 +1,38 @@
+package Net::HTTP::Console::Role::Plugins;
+
+use MooseX::Declare;
+
+role Net::HTTP::Console::Role::Plugins {
+
+ has dispatchers => (
+ is => 'rw',
+ isa => 'ArrayRef[Str]',
+ traits => ['Array'],
+ lazy => 1,
+ auto_deref => 1,
+ default => sub {
+ [qw/Load HTTP Help Method Set/],
+ }
+ );
+
+ has plugins => (
+ traits => ['Array'],
+ is => 'rw',
+ isa => 'ArrayRef[Object]',
+ lazy => 1,
+ handles => {all_plugins => 'elements', add_plugin => 'push'},
+ default => sub {
+ my $self = shift;
+ my @p;
+ for ($self->dispatchers) {
+ my $p = "Net::HTTP::Console::Dispatcher::" . $_;
+ Class::MOP::load_class($p);
+ my $o = $p->new(application => $self);
+ push @p, $o;
+ }
+ \@p;
+ },
+ );
+}
+
+1;