Skip to content

Instantly share code, notes, and snippets.

@pvenkatakrishnan
Last active January 3, 2016 10:09
Show Gist options
  • Save pvenkatakrishnan/8447964 to your computer and use it in GitHub Desktop.
Save pvenkatakrishnan/8447964 to your computer and use it in GitHub Desktop.
//the rule evaluation function is determined by properties: api || (module & api)
//the arguments passed to the api will be (req,rules)
//where rules is the property *rules* in ruleSet
//if just api is set, then rule engine would invoke that function with arguments assuming it is accessible in the namespace
//if module + api is set, then rule engine would require that module and invoke speced api on it.
//if neither module nor api is set, then the rule engine will try to evaluate on locals
//the rule implementation should return true/false
//rules will be evaluated with a switch case mentality. WHichever evaluates to truthy first will win
//the rules spec evaluation
//['foo', 'bar'] =====> (foo || bar)
//['foo', ['bar', 'blah']] =====> (foo || (bar & blah))
{
specialization: {
"salesPitchTemplate": [
{
"template": "highInterestRates",
"module": "seller",
"api": "gotDollars",
"rules" : {
"locale": ["en_US", "es_US"], // one of the locales should be satisfied
"experiment": ["foo", ["bar", "blah"] ], // one of the experiment specs need to be satisifed
"device": ["mobile", "tablet"] // one of the devices should be satisfied
}
},
{
"template": "shoppingOffers",
"module": "customer",
"api": "isAvidShopper",
"rules" : {
}
}
]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment