Module: Ovto

Defined in:
lib/ovto.rb,
lib/ovto/app.rb,
lib/ovto/state.rb,
lib/ovto/actions.rb,
lib/ovto/runtime.rb,
lib/ovto/version.rb,
lib/ovto/component.rb,
lib/ovto/wired_actions.rb

Defined Under Namespace

Classes: Actions, App, Component, Runtime, State, WiredActions

Constant Summary

VERSION =
'0.0.0'

Class Method Summary collapse

Class Method Details

.inspect(obj) ⇒ Object

JS-object-safe inspect



16
17
18
19
20
21
22
# File 'lib/ovto.rb', line 16

def self.inspect(obj)
  if `#{obj}.$$id`
    obj.inspect
  else
    `JSON.stringify(#{obj}) || "undefined"`
  end
end

.log_error(&block) ⇒ Object

Call block. If an exception is raised and there is a tag with `id='ovto-debug'`, describe the error in that tag



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ovto.rb', line 26

def self.log_error(&block)
  return block.call
rescue Exception => ex
  div = `document.getElementById('ovto-debug')`
  `console.log(document.getElementById('ovto-debug'))`
  if `div && !ex.OvtoPrinted`
    %x{
      div.textContent = "ERROR: " + #{ex.class.name};
      var ul = document.createElement('ul');
      // Note: ex.backtrace may be an Array or a String
      #{Array(ex.backtrace)}.forEach(function(line){
        var li = document.createElement('li');
        li.textContent = line;
        ul.appendChild(li);
      });
      div.appendChild(ul);
      ex.OvtoPrinted = true;
    }
  end
  raise ex
end