Class: NvimControl::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/nvim_control/controller.rb

Class Method Summary collapse

Class Method Details

.run(action:, payload:) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/nvim_control/controller.rb', line 8

def run(action:, payload:)
  return invalid_action_response unless supported_action?(action)

  JSON.generate(action_response(action: action, payload: payload))
rescue ConnectionError => e
  format_error("Connection failed", e.message)
rescue OperationError => e
  format_error("Control action failed", e.message)
rescue StandardError => e
  format_error("Unexpected error", e.message)
end

.supported_action?(action) ⇒ Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/nvim_control/controller.rb', line 20

def supported_action?(action)
  ACTIONS.key?(action)
end

.supported_actionsObject



24
25
26
# File 'lib/nvim_control/controller.rb', line 24

def supported_actions
  ACTIONS.keys
end