Class: Textus::Dispatch::HandlerRegistry
- Inherits:
-
Object
- Object
- Textus::Dispatch::HandlerRegistry
- Defined in:
- lib/textus/dispatch/handler_registry.rb
Instance Method Summary collapse
- #for(command_class) ⇒ Object
-
#initialize ⇒ HandlerRegistry
constructor
A new instance of HandlerRegistry.
- #register(command_class, handler) ⇒ Object
- #registered?(command_class) ⇒ Boolean
Constructor Details
#initialize ⇒ HandlerRegistry
Returns a new instance of HandlerRegistry.
4 5 6 |
# File 'lib/textus/dispatch/handler_registry.rb', line 4 def initialize @handlers = {} end |
Instance Method Details
#for(command_class) ⇒ Object
12 13 14 |
# File 'lib/textus/dispatch/handler_registry.rb', line 12 def for(command_class) @handlers[command_class] || raise("no handler registered for #{command_class}") end |
#register(command_class, handler) ⇒ Object
8 9 10 |
# File 'lib/textus/dispatch/handler_registry.rb', line 8 def register(command_class, handler) @handlers[command_class] = handler end |
#registered?(command_class) ⇒ Boolean
16 17 18 |
# File 'lib/textus/dispatch/handler_registry.rb', line 16 def registered?(command_class) @handlers.key?(command_class) end |