Method: Undead::Browser#command

Defined in:
lib/undead/browser.rb

#command(name, *args) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/undead/browser.rb', line 42

def command(name, *args)
  cmd = Undead::Command.new(name, *args)
  log cmd.message

  response = server.send(cmd)
  log response

  json = JSON.load(response)

  if json['error']
    klass = ERROR_MAPPINGS[json['error']['name']] || Undead::BrowserError
    raise klass.new(json['error'])
  else
    json['response']
  end
rescue Undead::DeadClient
  restart
  raise
end