✨ ARCANUM RUNE DIFFICULTY: Apprentice Structural

The Decorator (jq)

Dynamically weave new enchantments onto existing data structures.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Augmentation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
# Base component
def base_signal:
  { "data": "raw_feed", "cost": 10 };

# Decorators
def with_encryption:
  .data |= "ENCRYPTED(" + . + ")" | .cost += 15;
  
def with_compression:
  .data |= "COMPRESS(" + . + ")" | .cost += 5;

# Applying decorators dynamically
base_signal | with_encryption | with_compression

Why lock a structure into rigid subclassing when you can augment it on the fly? The Decorator pattern chains mutations across the JSON stream. Each decorator captures the object, alters its state or wraps its payload, and passes it forward. The final construct is a stack of harmonized enchantments.

Runic Tags: #jq #json #transmutation #gof