class Cassia::ResponseHandlers::GetConnectedDevicesRouter

Public Class Methods

new(access_controller, router: ) click to toggle source
# File lib/cassia/response_handlers/get_connected_devices_router.rb, line 4
def initialize(access_controller, router: )
  @access_controller = access_controller
  @router = router
end

Public Instance Methods

handle(response) click to toggle source
# File lib/cassia/response_handlers/get_connected_devices_router.rb, line 9
def handle(response)
  if response.success?
    handle_success(response)
  else
    handle_failure(response)
  end
  response.success?
end

Private Instance Methods

handle_failure(response) click to toggle source
# File lib/cassia/response_handlers/get_connected_devices_router.rb, line 28
def handle_failure(response)
  @access_controller.error = response.body
end
handle_success(response) click to toggle source
# File lib/cassia/response_handlers/get_connected_devices_router.rb, line 20
def handle_success(response)
  @router.connected_devices = response.body["nodes"].map do |device|
    new_device = Device.new(device)
    new_device.mac = device.delete("id")
    new_device
  end
end