Sha256: 3375b9415e8573c73ca3e2d5db51aa1a48e19bd995ab0e524227d257c9e8a04e

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

# Base Message class. Child classes should call super from #initialize and must
# implement #process.
class Message
  # (Mostly) Common message attributes
  attr_reader :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
  def initialize message
    @message = message
  end

  def message_type
    message.fetch 'message_type'
  end

  # NOTE: Subclass is expected to implement #process
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
test_driven_lighting-1.2.0 lib/test_driven_lighting/messages/message.rb
test_driven_lighting-1.1.0 lib/test_driven_lighting/messages/message.rb