Sha256: 96cb67c74bba99604bb73a32b7bd2eee0e013e0c66af1882fee8faefe064a67c
Contents?: true
Size: 613 Bytes
Versions: 3
Compression:
Stored size: 613 Bytes
Contents
module Commandoes UnknownCommand = Class.new StandardError RegistryNotFound = Class.new StandardError class Dispatcher def initialize(registry: nil) @registry = registry end def dispatch(command) raise RegistryNotFound unless registry.present? 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 private attr_reader :registry end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
commandoes-0.1.3 | lib/commandoes/dispatcher.rb |
commandoes-0.1.2 | lib/commandoes/dispatcher.rb |
commandoes-0.1.1 | lib/commandoes/dispatcher.rb |