3
0
mirror of https://github.com/pragma-/pbot.git synced 2024-11-20 02:49:49 +01:00

Registerable: add register_front method to register to head of list

This commit is contained in:
Pragmatic Software 2020-05-29 20:49:24 -07:00
parent c9be31a9c0
commit 52f183deae

View File

@ -54,6 +54,14 @@ sub register {
return $ref; return $ref;
} }
sub register_front {
my ($self, $subref) = @_;
Carp::croak("Must pass subroutine reference to register_front()") if not defined $subref;
my $ref = {subref => $subref};
unshift @{$self->{handlers}}, $ref;
return $ref;
}
sub unregister { sub unregister {
my ($self, $ref) = @_; my ($self, $ref) = @_;
Carp::croak("Must pass reference to unregister()") if not defined $ref; Carp::croak("Must pass reference to unregister()") if not defined $ref;