Created
June 26, 2009 17:25
-
-
Save jstotz/136610 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////// | |
// In the promotion rule application: | |
rule = new Rule(); | |
rule.callbacks.get_condition_options = function(type, property, operator, value) { | |
// Make AJAX call to services: | |
// GET /promos/rules/options?type=type&property=property&operator=operator&value=value | |
// Parse the server response into whatever return format is expected of this type of | |
// callback function (as defined by the general purpose rule system) | |
return { | |
types: [...] | |
properties: [...] | |
operators: [...] | |
value_options: [...] | |
} | |
}); | |
///////////////////////////////////// | |
// In the general purpose rule system: | |
Rule = function() { | |
this.callbacks = {}; | |
} | |
Condition = function(rule) { | |
this.rule = rule; | |
this.to_html= function() { | |
options = rule.callbacks.get_condition_options(); | |
// Do whatever you processing we need with those options to render html | |
return html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment