Class: Message

Inherits:
Object
  • Object
show all
Defined in:
lib/test_driven_lighting/messages/message.rb

Overview

Base Message class. Child classes should call super from #initialize and must implement #process.

Direct Known Subclasses

LogMessage

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Message

message: hash with string keys containing the message data. MUST contain at least “message_type” => “name_of_this_message” so we know which message class should handle it, though technically that’s all handled by MessageDispatcher before we ever construct the message



11
12
13
# File 'lib/test_driven_lighting/messages/message.rb', line 11

def initialize message
  @message = message
end

Instance Attribute Details

#messageObject (readonly)

(Mostly) Common message attributes



5
6
7
# File 'lib/test_driven_lighting/messages/message.rb', line 5

def message
  @message
end

Instance Method Details

#message_typeObject



15
16
17
# File 'lib/test_driven_lighting/messages/message.rb', line 15

def message_type
  message.fetch 'message_type'
end