♦️ RUBY ENCHANTMENTS DIFFICULTY: Apprentice Behavioral

The Command

Encapsulating a blood sacrifice as an invocable command, ready to be executed, delayed, or reversed.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Command
ARCANUM SCHOOL: Enchantment // Compulsion
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// DYNAMIC RUBY BLOOD MAGIC //
class BloodSacrificeCommand
  def initialize(victim, liters)
    @victim = victim
    @liters = liters
  end

  def execute
    "Draining #{@liters} liters from #{@victim}."
  end

  def undo
    "Transfusing #{@liters} liters back into #{@victim} (if they still live)."
  end
end

class RitualInvoker
  def initialize
    @history = []
  end

  def cast(command)
    @history << command
    command.execute
  end

  def reverse_last
    command = @history.pop
    command ? command.undo : "No rituals to reverse."
  end
end

The Command pattern turns a request into a stand-alone object. This allows a ritual invoker to queue up sacrifices, delay their execution until the moon is right, or even undo them if the demonic entity is displeased.

Runic Tags: #ruby #design-pattern #command #blood-magic