Class: React::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/react/console.rb

Class Method Summary collapse

Class Method Details

.polyfill_jsObject



3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/react/console.rb', line 3

def self.polyfill_js
  # Overwrite global `console` object with something that can capture messages
  # to return to client later for debugging
  "var console = { history: [] };\n['error', 'log', 'info', 'warn'].forEach(function (fn) {\nconsole[fn] = function () {\nconsole.history.push({level: fn, arguments: Array.prototype.slice.call(arguments)});\n};\n});\n"
end

.replay_as_script_jsObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/react/console.rb', line 16

def self.replay_as_script_js
  "(function (history) {\nif (history && history.length > 0) {\nresult += '\\\\n<scr'+'ipt>';\nhistory.forEach(function (msg) {\nresult += '\\\\nconsole.' + msg.level + '.apply(console, ' + JSON.stringify(msg.arguments) + ');';\n});\nresult += '\\\\n</scr'+'ipt>';\n}\n})(console.history);\n"
end