Class: CommandProcessor::Processor
- Inherits:
-
Object
- Object
- CommandProcessor::Processor
- Defined in:
- lib/command_processor/processor.rb
Instance Method Summary collapse
- #handle(command) ⇒ Object
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
- #register(*args, &block) ⇒ Object
Constructor Details
Instance Method Details
#handle(command) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/command_processor/processor.rb', line 14 def handle(command) handler_class = Object.const_get("#{command.class.name}Handler") handler = @container.resolve_by_type(handler_class) handler.handle(command) rescue ::IOC::UnknownServiceError raise(HandlerNotRegisteredError, "Expected handler of type '#{command.class.name}Handler' to be registered") end |
#register(*args, &block) ⇒ Object
10 11 12 |
# File 'lib/command_processor/processor.rb', line 10 def register(*args, &block) @container.register(*args, &block) end |