Skip to content

Commit

Permalink
Fix this.memory(key, falsy)
Browse files Browse the repository at this point in the history
  • Loading branch information
knu committed Jun 16, 2016
1 parent 4edb6e0 commit 806722b
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions app/models/agents/java_script_agent.rb
Expand Up @@ -114,12 +114,9 @@ def execute_js(js_function, incoming_events = [])
context["getOptions"] = lambda { |a, x| interpolated.to_json }
context["doLog"] = lambda { |a, x| log x }
context["doError"] = lambda { |a, x| error x }
context["getMemory"] = lambda do |a, x, y|
if x && y
memory[x] = clean_nans(y)
else
memory.to_json
end
context["getMemory"] = lambda { |a| memory.to_json }
context["setMemory"] = lambda do |a, x, y|
memory[x] = clean_nans(y)
end
context["deleteKey"] = lambda { |a, x| memory.delete(x).to_json }
context["escapeHtml"] = lambda { |a, x| CGI.escapeHTML(x) }
Expand Down Expand Up @@ -168,7 +165,7 @@ def setup_javascript
Agent.memory = function(key, value) {
if (typeof(key) !== "undefined" && typeof(value) !== "undefined") {
getMemory(key, value);
setMemory(key, value);
} else if (typeof(key) !== "undefined") {
return JSON.parse(getMemory())[key];
} else {
Expand Down

0 comments on commit 806722b

Please sign in to comment.