diff --git a/source/engine/mecanisms.js b/source/engine/mecanisms.js index 6a4dfc870..36be57fb4 100644 --- a/source/engine/mecanisms.js +++ b/source/engine/mecanisms.js @@ -222,8 +222,24 @@ export let mecanismAllOf = (recurse, k, v) => { /> ) + + let evaluate = (situationGate, parsedRules, node) => { + let evaluateOne = child => evaluateNode(situationGate, parsedRules, child), + explanation = R.map(evaluateOne, node.explanation), + values = R.pluck('nodeValue', explanation), + nodeValue = R.any(R.equals(false), values) + ? false // court-circuit + : R.any(R.equals(null), values) ? null : true + + let collectMissing = node => + node.nodeValue == null + ? R.chain(collectNodeMissing, node.explanation) + : [] + return rewriteNode(node, nodeValue, explanation, collectMissing) + } + return { - evaluate: evaluateArray(R.and, true), + evaluate: evaluate, jsx, explanation, category: 'mecanism',