Class: MessageHandler

Inherits:
Object
  • Object
show all
Includes:
Messenger
Defined in:
lib/socketeer/message_handler.rb

Instance Attribute Summary

Attributes included from Messenger

#in_queue, #out_queue

Instance Method Summary collapse

Methods included from Messenger

#bind_queues

Constructor Details

#initialize(&handler) ⇒ MessageHandler

Returns a new instance of MessageHandler.



10
11
12
# File 'lib/socketeer/message_handler.rb', line 10

def initialize &handler
  @handler = handler
end

Instance Method Details

#cycleObject



14
15
16
17
18
# File 'lib/socketeer/message_handler.rb', line 14

def cycle
  in_message = pop_message
  out_message = @handler.call in_message unless in_message.nil?
  push_message out_message
end