Class: Collab::JS::JSProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/collab/js.rb

Instance Method Summary collapse

Constructor Details

#initializeJSProcess

Returns a new instance of JSProcess.



59
60
61
62
63
64
65
# File 'lib/collab/js.rb', line 59

def initialize
   @node = if defined?(Rails)
             Dir.chdir(Rails.root) { open_node }
           else
             open_node
           end
end

Instance Method Details

#call(req) ⇒ Object



67
68
69
70
71
72
# File 'lib/collab/js.rb', line 67

def call(req)
  @node.puts(req)
  res = JSON.parse(@node.gets)
  raise ::Collab::JS::JSRuntimeError.new(res["error"]) if res["error"]
  res["result"]
end