NAME
Catalyst::Seal::Guard - replace a subroutine and keep the original
DESCRIPTION
Most of what this distribution does is install a replacement over somebody else's subroutine. This is where that happens, so that there is one place that knows what was there before.
The original matters at runtime and not only for tests. Several replacements call the subroutine they shadowed: Catalyst::Seal::Finalize falls back to the stock finalize_encoding for a response it has no answer for, and Catalyst::Seal::Construct calls the stock BUILD for anything that is not a plain context object. They reach it through %ORIGINAL.
replace
Catalyst::Seal::Guard::replace('Catalyst::handle_request', \&my_version);
Installs the replacement and remembers the original. Returns true when it did.
Returns false, without installing anything, when the named subroutine does not exist. A patch site that is not there is a Catalyst that is not the one this was written for, and installing a replacement for a subroutine nobody defined would create it rather than replace it.
restore
Puts the original subroutine back. For tests, for a step that installs a patch and then finds it cannot keep its side of the bargain, and for anyone who wants to undo one at runtime.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)