Module: Actor::Module::Handler

Included in:
Supervisor
Defined in:
lib/actor/module/handler.rb,
lib/actor/module/handler/macro.rb,
lib/actor/module/handler/method_name.rb,
lib/actor/module/handler/send_next_message.rb

Defined Under Namespace

Modules: Macro, MethodName, SendNextMessage

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(cls) ⇒ Object



4
5
6
7
8
# File 'lib/actor/module/handler.rb', line 4

def self.included cls
  cls.class_exec do
    extend Macro
  end
end

Instance Method Details

#handle(message) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/actor/module/handler.rb', line 10

def handle message
  handler_method_name = MethodName.get message

  return unless handler_method_name and respond_to? handler_method_name

  handler_method = method handler_method_name

  if handler_method.arity == 0
    handler_method.()
  else
    handler_method.(message)
  end
end