Skip to content

Instantly share code, notes, and snippets.

@simen
Created Dec 5, 2011
Embed
What would you like to do?
Match with constraint counting
"identity:7" => [1,2,4]
"realm:mittap" => [1,3,4]
"body:'Hello…' => [4]
1: rule: {identity: 7, realm: 'mittap'}, number_of_constraints: 2
2: rule: {identity: 7}, number_of_constraints: 1
3: rule: {identity: 8, realm: 'mittap'}, number_of_constraints: 2
4: rule: {identity: 7, realm: 'mittap', body: "Hello from number 7"}, number_of_constraints: 3
message = {identity: 7, body: "Hello from number 7"}
single_constraint_match = find_applicable_rules(message) => [1,2,4,1,3,4,4]
count_matches(single_constraint_match)
=> 1 => 2
2 => 1
3 => 1
4 => 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment