Skip to content

Instantly share code, notes, and snippets.

@fatum
Created January 19, 2017 14:00
Show Gist options
  • Save fatum/0a5fe018eac444b291437f03f6875069 to your computer and use it in GitHub Desktop.
Save fatum/0a5fe018eac444b291437f03f6875069 to your computer and use it in GitHub Desktop.
Sample
groups = [{
condition: "OR",
rules: []
}]
state = {}
def match_groups(groups)
groups.each do |group|
context = create_from(state)
case group[:condition]
when "OR"
group[:rules].any? { |rule| match(rule, context) }
when "AND"
group[:rules].all? { |rule| match(rule, context) }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment