This is a YAML-based rule processing enging. It relies on the RuleFactory class for producing new rule objects.
The engine is stack based. The contents of the stack may be obtained at any time by accessing the ‘stack’ property of the engine. Likewise, initial elements may be pushed onto the stack in order to initialize the engine before processing.
engine = RuleEngine.new( schema, contents ) engine.stack.push Array.new engine.process parameters = engine.stack.pop
This engine’s processing strategy is inspired by the one used in the Apache Digester project and in the Hivemind project.
Methods
Attributes
| [R] | stack | The stack used by the engine during processing. Rules may push values onto this stack, and pop them off. |
Public Class methods
Create a new engine which will process the given contents (a Hash), using the given schema (also a Hash) as the source for rule definitions.
[ show source ]
# File lib/copland/rule-engine.rb, line 61
61: def initialize( schema, contents )
62: @schema = schema
63: @contents = contents
64: @stack = []
65: end
Public Instance methods
Begin processing the contents.
[ show source ]
# File lib/copland/rule-engine.rb, line 68
68: def process
69: process_content( @schema, @contents )
70: end