pub-sub 0.0.4 → 1.0.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/hash.rb +8 -7
- 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: c40743db194975eb5a6157d9818dda65ecadbddef131c9b4048d61a26567ae67
|
4
|
+
data.tar.gz: 98e1db527cc5a8ddc442026857922afa800949da0054b5e53f1e7c6dfc71d0a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1342d94d8e4333fe598cf6419183ae4528be0aa9e4fe6f9bf1faf058f3a0409169be9585e6b93048c2460290cf32c1c0b9f4cd9090dda68bdc8450d1fcd65c81
|
7
|
+
data.tar.gz: 0f1b05c15ac460f40413a8530f44c87a0d44b1b2b277596d506f05632fcc1f275e83bace387b66f527ac0ea502c2b57d08f9db1da370f3056bb1e6c776949a6c
|
data/lib/pub_sub/hash.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require "request_store"
|
2
3
|
|
3
4
|
module PubSub
|
4
5
|
class Hash < Container
|
5
6
|
def initialize
|
6
|
-
|
7
|
+
RequestStore.store[:hash] = {}
|
7
8
|
end
|
8
9
|
|
9
10
|
def pub(event, args={})
|
10
|
-
iterable_subscriber_list =
|
11
|
+
iterable_subscriber_list = RequestStore.store[:hash][event]
|
11
12
|
return false unless iterable_subscriber_list
|
12
13
|
|
13
14
|
clazzes = retrieve_klasses(iterable_subscriber_list)
|
@@ -18,8 +19,8 @@ module PubSub
|
|
18
19
|
mutex = Mutex.new
|
19
20
|
|
20
21
|
mutex.synchronize do
|
21
|
-
|
22
|
-
|
22
|
+
RequestStore.store[:hash][event] = [] unless RequestStore.store[:hash][event]
|
23
|
+
RequestStore.store[:hash][event] << klazz_name unless RequestStore.store[:hash][event].include?(klazz_name)
|
23
24
|
end
|
24
25
|
true
|
25
26
|
end
|
@@ -28,9 +29,9 @@ module PubSub
|
|
28
29
|
mutex = Mutex.new
|
29
30
|
|
30
31
|
mutex.synchronize do
|
31
|
-
return false unless
|
32
|
-
|
33
|
-
|
32
|
+
return false unless RequestStore.store[:hash][event]
|
33
|
+
|
34
|
+
RequestStore.store[:hash][event].delete(klazz_name)
|
34
35
|
true
|
35
36
|
end
|
36
37
|
end
|