Class: CommandProcessor::Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/command_processor/processor.rb

Instance Method Summary collapse

Constructor Details

#initializeProcessor

Returns a new instance of Processor.



5
6
7
# File 'lib/command_processor/processor.rb', line 5

def initialize
  @container = Container.new
end

Instance Method Details

#execute(command) ⇒ Object



13
14
15
16
17
# File 'lib/command_processor/processor.rb', line 13

def execute(command)
  handler_class = Object.const_get("#{command.class.name}Handler")
  handler = @container.resolve_by_type(handler_class)
  handler.execute(command)
end

#register(*args, &block) ⇒ Object



9
10
11
# File 'lib/command_processor/processor.rb', line 9

def register(*args, &block)
  @container.register(*args, &block)
end