tiny_bus 3.4.1 → 3.5.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/tiny_bus.rb +8 -4
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6d3c857478866a08cee5481b5e6673e1113e796975cb050587a6ae7231c0071f
4
- data.tar.gz: 62360c6eda4448a72b3465321742920b7438e274817266b43ff408c014b73771
3
+ metadata.gz: 36e46c0df98b592b75546fb9949dce3b7ab566b36d2d45c2ad7875359ab20f6c
4
+ data.tar.gz: e82f99237803f759d119522db17eb7a8bf671bc6e74994442b74afe2aa22b941
5
5
  SHA512:
6
- metadata.gz: c48c7344e5506fb4ab40475167b2b6b2b6a6ab8a991222437e67f16bab9b5b3ad131256295552596679635b00a7b7278461c58dad5632f2b04fa696ff2d7f9b4
7
- data.tar.gz: dfe686720994f643787e7847a594296006643668696e54b4dfd8d9f372d6f2692839c7fa8a758eac7fefb282896cb3a6134628c8705ce8ded4e4ab033af32d7a
6
+ metadata.gz: ad7aa85c1d1054f68a8575421df286a7050a06f25798ef14c2ce9e0531d9d75dad9d99e1132503e49b46342b535abffe0aba8f42d6680e52d6d58ef6ce176f07
7
+ data.tar.gz: '03549a8c7363c88acff29cc86c7a2e9ce17f9beb94c324b8385e59614c6e7cdbdd764a0020a1627a2c7ff82d37617a1871600107e37d5dd6447aae0d8a8ea7aa'
data/lib/tiny_bus.rb CHANGED
@@ -83,19 +83,23 @@ class TinyBus
83
83
  @subs[topic] << subber
84
84
  @stats[topic] ||= 0
85
85
 
86
- msg({ @topic_key => 'sub', 'to_topic' => topic, 'subber' => subber.to_s }, 'TINYBUS-SUB')
86
+ msg({ @topic_key => 'sub', 'to_topic' => topic, 'subber' => _to_subber_id(subber) }, 'TINYBUS-SUB')
87
87
  end
88
88
 
89
89
  # removes a subscriber from a topic
90
90
  def unsub(topic, subber)
91
91
  @subs[topic]&.delete(subber)
92
92
 
93
- msg({ @topic_key => 'unsub', 'from_topic' => topic, 'subber' => subber.to_s }, 'TINYBUS-UNSUB')
93
+ msg({ @topic_key => 'unsub', 'from_topic' => topic, 'subber' => _to_subber_id(subber) }, 'TINYBUS-UNSUB')
94
+ end
95
+
96
+ def _to_subber_id(subber)
97
+ "#{subber.class.name}@#{subber.object_id}"
94
98
  end
95
99
 
96
100
  # takes an incoming message and distributes it to subscribers
97
101
  #
98
- # msg: the incoming message to be distributed
102
+ # msg: the incoming message to be distributed, must be a Ruby Hash
99
103
  # lvl (optional): the logging level
100
104
  # default: 'info'
101
105
  #
@@ -105,7 +109,7 @@ class TinyBus
105
109
  # NOTE: keys that begin with dot (.), such as '.time' are reserved for
106
110
  # TinyBus and show not be altered by outside code, otherwise undefined
107
111
  # behavior may result.
108
- def msg(msg, lvl='info')
112
+ def msg(msg, lvl=:info)
109
113
  msg = @annotator.pipe(msg)
110
114
  msg = @translator&.pipe(msg) || msg
111
115
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tiny_bus
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Lunt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-11 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tiny_log