Ruleby: The Rule Engine for Ruby
Author: ceefour | Filed under: Cool, Rails, Ruby, Tips, ToolsIf you're new here, you may want to subscribe to my RSS feed. Thanks for visiting!
Ruleby is a rule engine written in the Ruby language.
It is a system for executing a set of IF-THEN statements known as production rules. These rules are matched to objects using the forward chaining Rete algorithm. Ruleby provides an internal Domain Specific Language (DSL) for building the productions that make up a Ruleby program.
A rule engine is comprised of three parts:
- Facts – This is the data. It is known as the ‘working memory.
- Rules – the IF-THEN statements that define what valid data looks like
- Inference Engine – an efficient mechanism for executing the rules against the facts.
The Inference Engine in Ruleby is an implementation of the Rete algorithm. This is a forward chaining algorithm for matching patterns to objects. It was developed by Charles Forgy in his seminal paper Rete: a fast algorithm for the many pattern/many object pattern match problem.
How to use Ruleby?
Here is an example of a production rule in Ruleby (this example can be found in the Ruleby source code):
rule [Message, :m, m.status == :HELLO] do |e,v| puts v[:m].message v[:m].message = "Goodbye world" v[:m].status = :GOODBYE e.modify v[:m] end
For further details visit:
No related posts.
Related posts brought to you by Yet Another Related Posts Plugin.