Async::Container::SupervisorSourceAsyncContainerSupervisorDispatchable

module Dispatchable

A mixin for objects that can dispatch calls.

Provides automatic method dispatch based on the call's :do parameter.

Definitions

def dispatch(call)

Dispatch a call to the appropriate method.

Routes calls to methods named do_#{operation} based on the call's :do parameter.

Signature

parameter call Connection::Call

The call to dispatch.

Implementation

def dispatch(call)
	method_name = "do_#{call.message[:do]}"
	self.public_send(method_name, call)
rescue => error
	Console.error(self, "Error while dispatching call!", exception: error, call: call)
	
	call.fail(error: {
		class: error.class,
		message: error.message,
		backtrace: error.backtrace,
	})
end