Sha256: bb0586dfafd57e1071de129887cc6929b76f101c61da309bdb7b592d4253c154
Contents?: true
Size: 947 Bytes
Versions: 10
Compression:
Stored size: 947 Bytes
Contents
# frozen_string_literal: true # Base class for an event listener with DSL magic # # Usage: # class HelloListener < BasicEventListener # topic "hello", using_queue: "listener.hello" # # def world # puts "hello/world event received: #{message}" # end # end # class BasicEventListener attr_reader :message def initialize(message, _opts = {}) @message = message end def self.call_event(method_name, message, opts) new(message, opts).send(method_name.to_sym) end # Subclass exposes itself by declaring the event topic that it is going to listen for, # and an optional :using_queue parameter. # def self.topic(topic_name, params = {}) if params[:using_queue] Mimi::Messaging.register_event_processor_with_queue(topic_name, params[:using_queue], self) else Mimi::Messaging.register_event_processor(topic_name, params[:using_queue], self) end end end # class BasicEventListener
Version data entries
10 entries across 10 versions & 1 rubygems