| Hook-Queue documentation | view source | Contained in the Hook-Queue distribution. |
Hook::Queue - define a queue of handlers
# define a Liar class which always claims to be what you're asking
# about
package Liar;
use Hook::Queue 'UNIVERSAL::isa' => sub {
my $what = shift;
my $class = shift;
return 1 if (ref $what || $what) eq "Liar";
# it's not my call, pass it down the chain
return Hook::Queue->defer;
};
Hook::Queue provides a mechanism for stacking global handlers in a queue of routines that will take an attempt at answering the subroutine call addressed to it.
For each subroutine that joins the queue, it can either return a
canonical answer, or indicate that it's deferring along the queue by
calling the Hook::Queue-defer> method and returning.
When you say use Hook::Queue you join the queue at its current
head, and as such your position may very, depending on compilation
order of the Perl program. As such you should remember to defer
even if your testing shows you to be at the end of the queue in test
circumstances.
Richard Clamp <richardc@unixbeard.net>
Copyright Richard Clamp 2004. All Rights Reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
None known.
Bugs should be reported to me via the CPAN RT system. http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Hook::Queue.
SUPER, NEXT - for similar idioms for OO programming
| Hook-Queue documentation | view source | Contained in the Hook-Queue distribution. |