Abstract Factory
Weaving generational magic through abstract constructs in Raku.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Abstract Factory
ARCANUM SCHOOL: Conjuration // Threadmancy
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// RAKU PATTERN //
role Ward { method manifest() { ... } }
role Curse { method inflict() { ... } }
class CenturyWard does Ward {
method manifest() { say "A ward cast for 100 years." }
}
class CenturyCurse does Curse {
method inflict() { say "A 100-year curse is laid upon the land." }
}
role SpellFactory {
method create-ward(--> Ward) { ... }
method create-curse(--> Curse) { ... }
}
class CenturySpellFactory does SpellFactory {
method create-ward(--> Ward) { CenturyWard.new }
method create-curse(--> Curse) { CenturyCurse.new }
}
my SpellFactory $factory = CenturySpellFactory.new;
my Ward $ward = $factory.create-ward();
$ward.manifest();
The Hundred-Year Spell requires a weaver of immense patience. The Abstract Factory ensures that the threads of magic—whether wards or curses—are consistent across the generations, bound by a singular overarching factory of intent.
Runic Tags:
#creational
#abstract-factory
#raku
#hundred-year-spell