The Resolution Chain
Pass a request along a chain of magical handlers until one successfully processes it.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Divination // Leyline Routing
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The Request
SPELL_TIER ?= 1
# The Handlers in the chain
.PHONY: handle_tier_1 handle_tier_2 handle_tier_3 fallback
handle_tier_1:
@if [ "$(SPELL_TIER)" -eq 1 ]; then echo "Apprentice handled the tier 1 spell."; else $(MAKE) --no-print-directory handle_tier_2; fi
handle_tier_2:
@if [ "$(SPELL_TIER)" -eq 2 ]; then echo "Adept handled the tier 2 spell."; else $(MAKE) --no-print-directory handle_tier_3; fi
handle_tier_3:
@if [ "$(SPELL_TIER)" -eq 3 ]; then echo "Archmage handled the tier 3 spell."; else $(MAKE) --no-print-directory fallback; fi
fallback:
@echo "The spell fizzled. No mage could handle a tier $(SPELL_TIER) request."
# Entry point
.PHONY: process_spell
process_spell: handle_tier_1
Runic Tags:
#makefile
#behavioral
#chain-of-responsibility
#routing