🗼 EIFFEL CONTRACT DIFFICULTY: Adept Behavioral

The Chain of Responsibility Leyline

Passing requests through a sequence of warding nodes.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Chain of Responsibility
ARCANUM SCHOOL: Abjuration // Warding
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// EIFFEL PATTERN //
deferred class
    WARD_NODE

feature
    next_node: WARD_NODE

    set_next (node: WARD_NODE)
        do
            next_node := node
        ensure
            next_set: next_node = node
        end

    handle_intrusion (threat_level: INTEGER)
        do
            if can_handle (threat_level) then
                neutralize
            elseif next_node /= Void then
                next_node.handle_intrusion (threat_level)
            end
        end

    can_handle (threat_level: INTEGER): BOOLEAN
        deferred
        end

    neutralize
        deferred
        end
end

Incoming arcane threats are handed down a chain of progressively stronger wards, decoupling the threat from its ultimate neutralizing node.

Runic Tags: #behavioral #chain-of-responsibility #eiffel