The Factory Method (jq)
A focal point in the JSON stream to manifest specialized entities on demand.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Factory Method
ARCANUM SCHOOL: Conjuration // Summoning
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# The creator interface
def summon_entity($type):
if $type == "daemon" then
{ "entity": "Daemon", "protocol": "TCP", "port": 666, "status": "listening" }
elif $type == "sprite" then
{ "entity": "Sprite", "protocol": "UDP", "port": 1337, "status": "hovering" }
else
{ "error": "Unknown invocation" }
end;
# Stream processing
.requests[] | summon_entity(.desired_type)
The Factory Method provides a singular locus of creation. Rather than bleeding the logic of entity genesis throughout your scripts, we channel the ambient JSON flow into a single conjuration function. This filter breathes life into specific constructs based on the signatures detected in the incoming stream.
Runic Tags:
#jq
#json
#transmutation
#gof