Class: Overule::Context
- Inherits:
-
Object
- Object
- Overule::Context
- Defined in:
- lib/overule/context.rb
Overview
Maintains the state of facts and variables used in rule evaluation Provides methods to get and set values in the context Uses HashWithIndifferentAccess for flexible key access
Instance Attribute Summary collapse
-
#facts ⇒ Object
readonly
Returns the value of attribute facts.
Instance Method Summary collapse
- #get(key) ⇒ Object
-
#initialize(facts = {}) ⇒ Context
constructor
A new instance of Context.
- #set(key, value) ⇒ Object
Constructor Details
#initialize(facts = {}) ⇒ Context
Returns a new instance of Context.
10 11 12 |
# File 'lib/overule/context.rb', line 10 def initialize(facts = {}) @facts = HashWithIndifferentAccess.new(facts) end |
Instance Attribute Details
#facts ⇒ Object (readonly)
Returns the value of attribute facts.
8 9 10 |
# File 'lib/overule/context.rb', line 8 def facts @facts end |
Instance Method Details
#get(key) ⇒ Object
14 15 16 |
# File 'lib/overule/context.rb', line 14 def get(key) @facts[key] end |
#set(key, value) ⇒ Object
18 19 20 |
# File 'lib/overule/context.rb', line 18 def set(key, value) @facts[key] = value end |