🎲 R HARUSPEX DIFFICULTY: Adept Structural

The Decorator: Layering Enhancements

Dynamically adding arcane power to statistical models.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Divination // Augmentation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// R PATTERN //
library(R6)

# Component
BaseModel <- R6Class("BaseModel",
  public = list(
    evaluate = function() stop("Not implemented")
  )
)

# Concrete Component
LinearOmen <- R6Class("LinearOmen", inherit = BaseModel,
  public = list(
    evaluate = function() "Evaluating base linear omen."
  )
)

# Decorator
ModelDecorator <- R6Class("ModelDecorator", inherit = BaseModel,
  private = list(
    component = NULL
  ),
  public = list(
    initialize = function(component) {
      private$component <- component
    },
    evaluate = function() {
      private$component$evaluate()
    }
  )
)

# Concrete Decorator
BloodSacrificeDecorator <- R6Class("BloodSacrificeDecorator", inherit = ModelDecorator,
  public = list(
    evaluate = function() {
      base_result <- super$evaluate()
      paste(base_result, "Augmented with Blood Sacrifice (+5 accuracy).")
    }
  )
)

Wrap standard scrying models in Decorators to inject additional powers, like caching, logging, or arcane sacrifices, without modifying the core algorithms.

Runic Tags: #R6 #Divination #Structural #Decorator