class Commandos::Dispatcher
Attributes
registry[R]
Public Class Methods
new(registry: nil)
click to toggle source
# File lib/commandos/dispatcher.rb, line 6 def initialize(registry: nil) @registry = registry end
Public Instance Methods
dispatch(command) { |result| ... }
click to toggle source
# File lib/commandos/dispatcher.rb, line 10 def dispatch(command) raise RegistryNotFound if registry.nil? raise UnknownCommand unless command.kind_of? IAmACommand registry.find_by command do |handler| handler = handler.new command result = handler.call if block_given? yield result end return result end end