Class: HaveAPI::Fs::RemoteControl

Inherits:
Object
  • Object
show all
Defined in:
lib/haveapi/fs/remote_control.rb

Overview

The purpose of this class is to handle commands received via the Components::RemoteControlFile.

Class Method Summary collapse

Class Method Details

.execute(context, path) ⇒ Object

Call method #exec of a component at path.

Parameters:



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/haveapi/fs/remote_control.rb', line 9

def self.execute(context, path)
  c = context.fs.send(:find_component, path)

  ret = c.exec

  case ret
  when true
    {status: true}

  when HaveAPI::Client::Response
    {status: ret.ok?, message: ret.message, errors: ret.errors}

  when HaveAPI::Client::ValidationError
    {status: false, message: ret.message, errors: ret.errors}

  else
    {status: false, message: 'unknown response'}
  end
end