messaging 3.4.1 → 3.5.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Messaging
4
- # @private
5
- # @deprecated
6
- class BaseHandler
7
- class << self
8
- def only_messages(messages = nil)
9
- @only_messages = Array(messages) if messages
10
- @only_messages || []
11
- end
12
- alias only_message only_messages
13
-
14
- def group_id(group_id = nil)
15
- @group_id = group_id if group_id
16
- @group_id || default_group_id
17
- end
18
-
19
- def default_group_id
20
- Config.app_name + '-' + name.underscore
21
- end
22
-
23
- def call(message)
24
- return unless allowed_message?(message.class)
25
-
26
- new.on_message(message, nil)
27
- end
28
-
29
- def listen_on(topic:)
30
- topics = Array(topic).map(&:to_s)
31
- Messaging.routes.consumer(name, group_id: group_id) do |c|
32
- topics.each { |t| c.on(/.*/, topic: t, call: self) }
33
- end
34
- end
35
-
36
- def allowed_message?(message_class)
37
- return true if only_messages.empty?
38
-
39
- only_messages.include? message_class
40
- end
41
- end
42
-
43
- def on_message(message, _metadata); end
44
- end
45
- end