plugin metaclass, profiles, commands plugi
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Meta / Plugin.pm
diff --git a/lib/Devel/REPL/Meta/Plugin.pm b/lib/Devel/REPL/Meta/Plugin.pm
new file mode 100644 (file)
index 0000000..c9cca5f
--- /dev/null
@@ -0,0 +1,21 @@
+package Devel::REPL::Meta::Plugin;
+
+use Moose;
+
+extends 'Moose::Meta::Role';
+
+before 'apply' => sub {
+  my ($self, $other) = @_;
+  if (my $pre = $self->get_method('BEFORE_PLUGIN')) {
+    $pre->body->($other, $self);
+  }
+};
+
+after 'apply' => sub {
+  my ($self, $other) = @_;
+  if (my $pre = $self->get_method('AFTER_PLUGIN')) {
+    $pre->body->($other, $self);
+  }
+};
+
+1;