pub-sub 1.0.0 → 1.1.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
  SHA256:
3
- metadata.gz: c40743db194975eb5a6157d9818dda65ecadbddef131c9b4048d61a26567ae67
4
- data.tar.gz: 98e1db527cc5a8ddc442026857922afa800949da0054b5e53f1e7c6dfc71d0a6
3
+ metadata.gz: 18bca2d330b775c1afc4f5c6c156184a24e1460659d0eaeb39a04303d9c60e28
4
+ data.tar.gz: 02bcc7b0b46ddabcea84f7fb903adc22dfead7564aa57e151525ab0d3f55a3e7
5
5
  SHA512:
6
- metadata.gz: 1342d94d8e4333fe598cf6419183ae4528be0aa9e4fe6f9bf1faf058f3a0409169be9585e6b93048c2460290cf32c1c0b9f4cd9090dda68bdc8450d1fcd65c81
7
- data.tar.gz: 0f1b05c15ac460f40413a8530f44c87a0d44b1b2b277596d506f05632fcc1f275e83bace387b66f527ac0ea502c2b57d08f9db1da370f3056bb1e6c776949a6c
6
+ metadata.gz: 54a57a74bf1ef5b21cf7288230d0d1d5abf59168e921f849f74a2a5d40243242ca9f034530dce802a4838c99d5756d3c6e8cad4f9d0ba14b2addbe5fec50b70f
7
+ data.tar.gz: a559cc034c86649608edcc8261e6f874cb90ce90f37784329c35ab3c27aa6d0fedc8cd49b608acb5fd1acd1760b620e8ad85cb68f1082597fc2269c39b6ae477
@@ -3,6 +3,7 @@ require 'singleton'
3
3
 
4
4
  require 'pub_sub/container'
5
5
  require 'pub_sub/hash'
6
+ require 'pub_sub/request_store'
6
7
  require 'pub_sub/publisher'
7
8
  require 'pub_sub/subscriber'
8
9
 
@@ -23,7 +23,7 @@ module PubSub
23
23
 
24
24
  def fan_out(clazzes, args)
25
25
  mutex = Mutex.new
26
-
26
+
27
27
  mutex.synchronize do
28
28
  clazzes.each{ |clazz| clazz.call(args) }
29
29
  true
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 = RequestStore.store[:hash][event]
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
- 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
+ @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 RequestStore.store[:hash][event]
33
+ return false unless @container[event]
33
34
 
34
- RequestStore.store[:hash][event].delete(klazz_name)
35
+ @container[event].delete(klazz_name)
35
36
  true
36
37
  end
37
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pub-sub
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Saltykov