Sha256: 5ee00c961beb927696fbae2f8514854b5db247eabc03f3b1e803d46e5cd4b59a
Contents?: true
Size: 578 Bytes
Versions: 1
Compression:
Stored size: 578 Bytes
Contents
module Koine module CommandBus class CommandBus UnhandledCommandError = Class.new(RuntimeError) attr_reader :resolvers def initialize(resolvers = []) @resolvers = resolvers end def handle(command) handler_for(command).handle(command) end def handler_for(command) resolvers.each do |resolver| handler = resolver.resolve(command) return handler if handler end raise UnhandledCommandError, "Command '#{command.class}' could not be handled" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
koine-command_bus-1.0.0 | lib/koine/command_bus/command_bus.rb |