class Cassia::ResponseHandlers::DiscoverAllServices
Public Class Methods
new(access_controller, router: , device_mac: )
click to toggle source
# File lib/cassia/response_handlers/discover_all_services.rb, line 4 def initialize(access_controller, router: , device_mac: ) @access_controller = access_controller @router = router @device_mac = device_mac end
Public Instance Methods
handle(response)
click to toggle source
# File lib/cassia/response_handlers/discover_all_services.rb, line 10 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/discover_all_services.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/discover_all_services.rb, line 21 def handle_success(response) device = @router.connected_devices.detect {|device| device.mac == @device_mac} response.body.each do |service| device.services << Service.new(service) end end