@rule.js/contextualize
v0.17.1
Published
Serializable object assertions.
Downloads
3
Maintainers
Readme
Rule.js: Contextualize
The idea behind this module is to allow to bind properties on
every call done to a Rule
object as though the property was
present on every object you're testing against. This allows,
for example, one to use the elasticsearch generator with
user login data. For example:
const Rule = require('@rule.js/core').extend({
contextualize: require('@rule.js/contextualize'),
elasticsearch: require('@rule.js/elasticsearch')
})
const condition = Rule()
.propEqual('user.name', 'creator')
const query = condition
.contextualize({
user: {
name: 'foobar'
}
})
.elasticsearch()
The query
variable would then contain an elasticsearch query which looks
like the following:
{
"term": {
"creator": "foobar"
}
}