new Manager(ruleStores, opts)
Constructor for Authority Manager.
Parameters:
Name | Type | Argument | Description |
---|---|---|---|
ruleStores |
object | Array.<object> |
<optional> |
An object or an array of objects capable of storing rules. If ommited, MemoryStore is used. |
opts |
object |
<optional> |
Additional options. |
- Source:
Methods
-
execute(rule, fact, done) → {null}
-
Executes the specified or provided rule.
Parameters:
Name Type Description rule
string | object The name of a rule or an instance of a rule.
fact
object An object containing facts to which the current rule is matched against.
done
function Callback function that will be called after the rule has been evaluated. The first parameter will be an error object if an error occurred, or null otherwise. The second parameter will contain
true
orfalse
indicating whether all conditions against the provided fact have been satisfied, including all conditions from all nested rules if any.- Source:
Returns:
- Type
- null
-
getRule(name, done) → {null}
-
Retrieves the specified rule from the first store that matches the name.
Parameters:
Name Type Description name
string The name of the rule.
done
function The callback that handles the result. The first parameter will be an error object if an error occurred, or null otherwise. The second parameter will contain the requested rule or null if not found.
- Source:
Returns:
- Type
- null
-
setRules(rules, override, done) → {null}
-
Adds one or more rules to the default store.
This method is simply alias to the
setRules
method of the default store. If default store hasn't been set explicitly, the first store in the collection is assumed.Parameters:
Name Type Argument Description rules
object | Array.<object> The rule or an array of rules to be added to the store.
override
boolean <optional>
Specifies whether existing rules should be replaced by the ones provided to this method. Rules are matched by their name. If this parameter is not specified or is false and there is a name conflict an error will be returned or thrown depending on the usage of the method.
done
function <optional>
Optional callback function that will be called after the rule(s) have been added. If the method is unsuccessful an error object will be passed as a single parameter to the callback. If the callback is omitted and the method is unsuccessful an error will be thrown.
- Source:
Returns:
- Type
- null