|
|
@@ -67,19 +67,7 @@ module Agents
|
67
|
67
|
end
|
68
|
68
|
true
|
69
|
69
|
end
|
70
|
|
- def setter_and_getter_memory(incoming_events = "")
|
71
|
|
- context = V8::Context.new
|
72
|
|
- context.eval(example_js)
|
73
|
|
- context["create_event"] = lambda {|x,y| puts x; puts y; create_event payload: JSON.parse(y)}
|
74
|
|
- context["access_memory"] = lambda {|a, x, y| x && y ? (memory[x] = y; memory.to_json) : memory.to_json }
|
75
|
70
|
|
76
|
|
- context.eval(options['code']) # should override the run function.
|
77
|
|
- a, e, o = [self.attributes.to_json, incoming_events.to_json, self.options.to_json]
|
78
|
|
- string = "a = new Agent('#{e}','#{o}','#{a}');"
|
79
|
|
- context.eval(string)
|
80
|
|
- binding.pry
|
81
|
|
- context.eval("a.memory()")
|
82
|
|
- end
|
83
|
71
|
def execute_js(incoming_events)
|
84
|
72
|
context = V8::Context.new
|
85
|
73
|
context.eval(example_js)
|
|
|
@@ -90,9 +78,9 @@ module Agents
|
90
|
78
|
a, e, o = [self.attributes.to_json, incoming_events.to_json, self.options.to_json]
|
91
|
79
|
string = "a = new Agent('#{e}','#{o}','#{a}');"
|
92
|
80
|
context.eval(string)
|
93
|
|
- context.eval("a.memory('5','6')") # set memory for testing
|
94
|
81
|
context.eval("a.run();")
|
95
|
82
|
end
|
|
83
|
+
|
96
|
84
|
def check
|
97
|
85
|
execute_js("")
|
98
|
86
|
end
|