wet-command_bus 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 62d9843340ef7d32403570a92a743755b076f8bb
4
- data.tar.gz: 4fc0afb881d2dcb5a5b51ddcdf97ae0af53de0d8
3
+ metadata.gz: 5fa4aa297bb92a522ed2a4011804db9ee473a916
4
+ data.tar.gz: e555fe97983c8e152b4231131166324f6f177e79
5
5
  SHA512:
6
- metadata.gz: 6ea3bd3a9dfb45c44e1df66b901f40e23b0be59f846518106b9dbd8a89c539eb4c5d1d1d2dfc22a5cef62226fd4cd812ee37f1f6a034da9218cd93d34f3817ff
7
- data.tar.gz: 8fb81565b70e79f3897870acd6847052c6169582ae333e3f700b7fbd203dff356065f9553ad125f23ea9197f913260812630db45cbde8a8f2b96b203883ad4e3
6
+ metadata.gz: 4c0df79fe2c3d3cf1280eeebc6ae61309a434591ba46c59fa9bd6621a007d8c5e7ff1f3e53712ad303626b87d2475c645778256f4e326444e638f927780dbf4e
7
+ data.tar.gz: 2a2652e7889bf4a2fcc1f90e431f5dfa31d0a14e9c58c5add4982adc2cac668fd093611eeae4270073e9721992ab6c6d2671f94b09ab5b3f6ab0b3dd84f5ab20
@@ -1,3 +1,7 @@
1
+ ### 0.3.0
2
+
3
+ * Make sure there is only one handler per command registered.
4
+
1
5
  ### 0.2.0
2
6
 
3
7
  * Rename and namespacing under `Wet` in order to release on RubyGems.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # CommandBus
1
+ # Wet::CommandBus
2
2
 
3
3
  > Command Pattern - decoupling what is done from who does it.
4
4
 
@@ -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(message(command)) }
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
@@ -1,5 +1,5 @@
1
1
  module Wet
2
2
  class CommandBus
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wet-command_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arkency