Sha256: 67e203c9eee141227f01b9aaf8386c191721a4e54818857bf7c649851711c8fb
Contents?: true
Size: 1.04 KB
Versions: 2
Compression:
Stored size: 1.04 KB
Contents
# frozen_string_literal: true module Messaging # @private # @deprecated class BaseHandler class << self def only_messages(messages = nil) @only_messages = Array(messages) if messages @only_messages || [] end alias only_message only_messages def group_id(group_id = nil) @group_id = group_id if group_id @group_id || default_group_id end def default_group_id Config.app_name + '-' + name.underscore end def call(message) return unless allowed_message?(message.class) new.on_message(message, nil) end def listen_on(topic:) topics = Array(topic).map(&:to_s) Messaging.routes.consumer(name, group_id: group_id) do |c| topics.each { |t| c.on(->(m) { m.topic == t }, call: self) } end end def allowed_message?(message_class) return true if only_messages.empty? only_messages.include? message_class end end def on_message(message, _metadata); end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
messaging-3.4.3 | lib/messaging/base_handler.rb |
messaging-3.4.2 | lib/messaging/base_handler.rb |