* Sets the conditions to run when evaluating the rule. * @param {object} conditions - conditions, root element must be a boolean operator
(conditions)
| 71 | * @param {object} conditions - conditions, root element must be a boolean operator |
| 72 | */ |
| 73 | setConditions (conditions) { |
| 74 | if ( |
| 75 | !Object.prototype.hasOwnProperty.call(conditions, 'all') && |
| 76 | !Object.prototype.hasOwnProperty.call(conditions, 'any') && |
| 77 | !Object.prototype.hasOwnProperty.call(conditions, 'not') && |
| 78 | !Object.prototype.hasOwnProperty.call(conditions, 'condition') |
| 79 | ) { |
| 80 | throw new Error( |
| 81 | '"conditions" root must contain a single instance of "all", "any", "not", or "condition"' |
| 82 | ) |
| 83 | } |
| 84 | this.conditions = new Condition(conditions) |
| 85 | return this |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Sets the event to emit when the conditions evaluate truthy |
no outgoing calls