pub-sub 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pub_sub/configuration.rb +1 -0
- data/lib/pub_sub/container.rb +1 -1
- data/lib/pub_sub/hash.rb +7 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18bca2d330b775c1afc4f5c6c156184a24e1460659d0eaeb39a04303d9c60e28
|
4
|
+
data.tar.gz: 02bcc7b0b46ddabcea84f7fb903adc22dfead7564aa57e151525ab0d3f55a3e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54a57a74bf1ef5b21cf7288230d0d1d5abf59168e921f849f74a2a5d40243242ca9f034530dce802a4838c99d5756d3c6e8cad4f9d0ba14b2addbe5fec50b70f
|
7
|
+
data.tar.gz: a559cc034c86649608edcc8261e6f874cb90ce90f37784329c35ab3c27aa6d0fedc8cd49b608acb5fd1acd1760b620e8ad85cb68f1082597fc2269c39b6ae477
|
data/lib/pub_sub/container.rb
CHANGED
data/lib/pub_sub/hash.rb
CHANGED
@@ -1,14 +1,15 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "request_store"
|
3
4
|
|
4
5
|
module PubSub
|
5
6
|
class Hash < Container
|
6
7
|
def initialize
|
7
|
-
RequestStore.store[:hash] = {}
|
8
|
+
@container = ::RequestStore.store[:hash] = {}
|
8
9
|
end
|
9
10
|
|
10
11
|
def pub(event, args={})
|
11
|
-
iterable_subscriber_list =
|
12
|
+
iterable_subscriber_list = @container[event]
|
12
13
|
return false unless iterable_subscriber_list
|
13
14
|
|
14
15
|
clazzes = retrieve_klasses(iterable_subscriber_list)
|
@@ -19,8 +20,8 @@ module PubSub
|
|
19
20
|
mutex = Mutex.new
|
20
21
|
|
21
22
|
mutex.synchronize do
|
22
|
-
|
23
|
-
|
23
|
+
@container[event] = [] unless @container[event]
|
24
|
+
@container[event] << klazz_name unless @container[event].include?(klazz_name)
|
24
25
|
end
|
25
26
|
true
|
26
27
|
end
|
@@ -29,9 +30,9 @@ module PubSub
|
|
29
30
|
mutex = Mutex.new
|
30
31
|
|
31
32
|
mutex.synchronize do
|
32
|
-
return false unless
|
33
|
+
return false unless @container[event]
|
33
34
|
|
34
|
-
|
35
|
+
@container[event].delete(klazz_name)
|
35
36
|
true
|
36
37
|
end
|
37
38
|
end
|