Sha256: 7371893be32ea31dcebdb0497c4d6cc85130c7aa2ffd468ddba5414185662e8e

Contents?: true

Size: 1000 Bytes

Versions: 1

Compression:

Stored size: 1000 Bytes

Contents

module Maitredee
  class Publisher
    class << self
      def call(*args)
        publisher = new(*args)
        publisher.process
        publisher.published_messages
      end

      def publish_defaults(topic_name: nil, event_name: nil, schema_name: nil)
        @publish_defaults = {
          topic_name: topic_name,
          event_name: event_name,
          schema_name: schema_name
        }
      end

      def get_publish_defaults
        @publish_defaults
      end
    end

    def published_messages
      @published_messages ||= []
    end

    def publish(topic_name: nil, event_name: nil, schema_name: nil, primary_key: nil, body:)
      defaults = self.class.get_publish_defaults
      published_messages << Maitredee.publish(
        topic_name: topic_name || defaults[:topic_name],
        event_name: event_name || defaults[:event_name],
        schema_name: schema_name || defaults[:schema_name],
        primary_key: primary_key,
        body: body
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
maitredee-0.8.2 lib/maitredee/publisher.rb