Class: Overule::Context

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#factsObject (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