r61346@onn: sartak | 2008-05-31 12:56:47 -0400
[p5sagit/Devel-REPL.git] / lib / Devel / REPL / Plugin / Completion.pm
index b4bbb88..05fca4f 100644 (file)
@@ -24,23 +24,21 @@ has no_term_class_warning => (
   default => 0,
 );
 
-sub BEFORE_PLUGIN {
+before 'read' => sub {
   my ($self) = @_;
 
+  unless ($self->term->isa("Term::ReadLine::Gnu") and !$self->no_term_class_warning) {
+    warn "Term::ReadLine::Gnu is required for the Completion plugin to work";
+    $self->no_term_class_warning(1);
+  }
+
   my $weakself = $self;
   weaken($weakself);
 
   $self->term->Attribs->{attempted_completion_function} = sub {
     $weakself->_completion(@_);
   };
-}
-
-sub AFTER_PLUGIN {
-  my ($self) = @_;
-
-  warn "Term::ReadLine::Gnu is required for the Completion plugin to work"
-    unless $self->term->isa("Term::ReadLine::Gnu") and !$self->no_term_class_warning;
-}
+};
 
 sub _completion {
   my ($self, $text, $line, $start, $end) = @_;