The Factory Method Hex
A method to dynamically weave derivations based on type signatures.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Pure Environment Hexes
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
{ lib ? import <nixpkgs/lib> }:
let
# The Factory Method
createHex = hexType:
if hexType == "bind" then { type = "bind"; effect = "Restricts movement."; energy = 10; }
else if hexType == "banish" then { type = "banish"; effect = "Sends entity to the Void."; energy = 50; }
else throw "Unknown hex type: ''${hexType}";
# Invocations
lesserBinding = createHex "bind";
abyssalBanishment = createHex "banish";
in
{
inherit lesserBinding abyssalBanishment;
}
The Factory Method provides an abstraction layer over raw attribute set creation. By parameterizing the instantiation, the archmage delegates the exact specification of the hex to the method, simplifying the calling code and enforcing structural consistency.
Runic Tags:
#creational
#factory-method
#nix
#parameters