wet-command_bus 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/wet/command_bus.rb +3 -5
- data/lib/wet/command_bus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5fa4aa297bb92a522ed2a4011804db9ee473a916
|
4
|
+
data.tar.gz: e555fe97983c8e152b4231131166324f6f177e79
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c0df79fe2c3d3cf1280eeebc6ae61309a434591ba46c59fa9bd6621a007d8c5e7ff1f3e53712ad303626b87d2475c645778256f4e326444e638f927780dbf4e
|
7
|
+
data.tar.gz: 2a2652e7889bf4a2fcc1f90e431f5dfa31d0a14e9c58c5add4982adc2cac668fd093611eeae4270073e9721992ab6c6d2671f94b09ab5b3f6ab0b3dd84f5ab20
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/wet/command_bus.rb
CHANGED
@@ -4,6 +4,7 @@ require 'thread_safe'
|
|
4
4
|
module Wet
|
5
5
|
class CommandBus
|
6
6
|
UnregisteredHandler = Class.new(StandardError)
|
7
|
+
MultipleHandlers = Class.new(StandardError)
|
7
8
|
|
8
9
|
def initialize
|
9
10
|
@handlers =
|
@@ -11,20 +12,17 @@ module Wet
|
|
11
12
|
end
|
12
13
|
|
13
14
|
def register(klass, handler)
|
15
|
+
raise MultipleHandlers.new("Multiple handlers not allowed for #{klass}") if handlers[klass]
|
14
16
|
handlers[klass] = handler
|
15
17
|
end
|
16
18
|
|
17
19
|
def call(command)
|
18
20
|
handlers
|
19
|
-
.fetch(command.class) { raise UnregisteredHandler.new(
|
21
|
+
.fetch(command.class) { raise UnregisteredHandler.new("Missing handler for #{command.class}") }
|
20
22
|
.(command)
|
21
23
|
end
|
22
24
|
|
23
25
|
private
|
24
26
|
attr_reader :handlers
|
25
|
-
|
26
|
-
def message(command)
|
27
|
-
"Missing handler for #{command.class}"
|
28
|
-
end
|
29
27
|
end
|
30
28
|
end
|