Class: Textus::Dispatch::HandlerRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/textus/dispatch/handler_registry.rb

Instance Method Summary collapse

Constructor Details

#initializeHandlerRegistry

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

Returns:

  • (Boolean)


16
17
18
# File 'lib/textus/dispatch/handler_registry.rb', line 16

def registered?(command_class)
  @handlers.key?(command_class)
end