Sha256: 6c270fb57a31b148e5b4de385a92260bda9ab1d85a53cf2e3644753943daf101
Contents?: true
Size: 566 Bytes
Versions: 2
Compression:
Stored size: 566 Bytes
Contents
class MessageDispatcher attr_reader :message_classes def initialize # message_classes contains "class_name" => ClassName @message_classes = {} end def register_message_class(name, klass) # screw trying to upcase and snake case and pretend to be rails WE'RE NOT # RAILS SO STOP TRYING message_classes[name] = klass end def dispatch(outgoing_message) klass = class_for outgoing_message.fetch("message_type") klass.new(outgoing_message).process end def class_for(class_name) message_classes.fetch class_name end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
test_driven_lighting-1.2.0 | lib/test_driven_lighting/message_dispatcher.rb |
test_driven_lighting-1.1.0 | lib/test_driven_lighting/message_dispatcher.rb |