The Proxy Hex
Controlling access or intercepting evaluation of derivations.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Transmutation // Pure Environment Hexes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
let
# The real subject, an expensive evaluation
expensiveSpell = {
data = builtins.trace "Evaluating Expensive Spell..." "Ultimate Destruction";
};
# The Proxy controls access, perhaps adding authorization or caching
spellProxy = user:
if user == "Archmage" then
expensiveSpell.data
else
"Access Denied: You lack the clearance.";
in
{
apprenticeAttempt = spellProxy "Apprentice";
archmageAttempt = spellProxy "Archmage";
}
The Proxy intercepts requests to the real subject. In Nix, thanks to lazy evaluation, the expensiveSpell is never actually evaluated if the Proxy denies access, serving as both a security ward and a performance optimization.
Runic Tags:
#structural
#proxy
#nix
#control