Class: MessageDispatcher
- Inherits:
-
Object
- Object
- MessageDispatcher
- Defined in:
- lib/test_driven_lighting/message_dispatcher.rb
Instance Attribute Summary collapse
-
#message_classes ⇒ Object
readonly
Returns the value of attribute message_classes.
Instance Method Summary collapse
- #class_for(class_name) ⇒ Object
- #dispatch(outgoing_message) ⇒ Object
-
#initialize ⇒ MessageDispatcher
constructor
A new instance of MessageDispatcher.
- #register_message_class(name, klass) ⇒ Object
Constructor Details
#initialize ⇒ MessageDispatcher
Returns a new instance of MessageDispatcher.
3 4 5 6 |
# File 'lib/test_driven_lighting/message_dispatcher.rb', line 3 def initialize # message_classes contains "class_name" => ClassName = {} end |
Instance Attribute Details
#message_classes ⇒ Object (readonly)
Returns the value of attribute message_classes.
2 3 4 |
# File 'lib/test_driven_lighting/message_dispatcher.rb', line 2 def end |
Instance Method Details
#class_for(class_name) ⇒ Object
19 20 21 |
# File 'lib/test_driven_lighting/message_dispatcher.rb', line 19 def class_for(class_name) .fetch class_name end |
#dispatch(outgoing_message) ⇒ Object
14 15 16 17 |
# File 'lib/test_driven_lighting/message_dispatcher.rb', line 14 def dispatch() klass = class_for .fetch("message_type") klass.new().process end |
#register_message_class(name, klass) ⇒ Object
8 9 10 11 12 |
# File 'lib/test_driven_lighting/message_dispatcher.rb', line 8 def (name, klass) # screw trying to upcase and snake case and pretend to be rails WE'RE NOT # RAILS SO STOP TRYING [name] = klass end |