The Proxy: Guarding the Core
A surrogate that controls access to the main divination model.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Proxy
ARCANUM SCHOOL: Divination // Ward
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// R PATTERN //
library(R6)
# Subject Interface
Oracle <- R6Class("Oracle",
public = list(
query = function() stop("Not implemented")
)
)
# Real Subject
TrueOracle <- R6Class("TrueOracle", inherit = Oracle,
public = list(
query = function() {
"The true future reveals itself..."
}
)
)
# Proxy
OracleProxy <- R6Class("OracleProxy", inherit = Oracle,
private = list(
true_oracle = NULL,
credentials_valid = FALSE
),
public = list(
initialize = function(password) {
if (password == "blood") {
private$credentials_valid <- TRUE
}
},
query = function() {
if (private$credentials_valid) {
if (is.null(private$true_oracle)) {
private$true_oracle <- TrueOracle$new()
}
return(private$true_oracle$query())
} else {
return("Access Denied. You lack the proper wards.")
}
}
)
)
The Proxy defers initialization of the True Oracle until absolutely necessary, and enforces strict access control through arcane passwords.
Runic Tags:
#R6
#Divination
#Structural
#Proxy