Sha256: 41441d4310f6c54bc4b91576bdcf72d2909d9a325cdfe46fa771f8be98a0a9ed

Contents?: true

Size: 702 Bytes

Versions: 12

Compression:

Stored size: 702 Bytes

Contents

# frozen_string_literal: true

module Msgr
  class Consumer
    include Logging

    attr_reader :message
    delegate :payload, to: :@message
    delegate :action, to: :'@message.route'
    delegate :consumer, to: :'@message.consumer'

    def dispatch(message)
      @message = message

      action = message.route.action.to_sym

      unless respond_to?(action)
        raise Msgr::NoAction.new \
          "No action `#{action}` for `#{self.class.name}`."
      end

      log(:debug) { "Invoke action #{action.inspect}." }

      send action

      log(:debug) { "Action #{action.inspect} done." }
    end

    def publish(data, opts = {})
      Msgr.client.publish(data, opts)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
msgr-0.15.2.1.b175 lib/msgr/consumer.rb
msgr-0.15.2.1.b169 lib/msgr/consumer.rb
msgr-0.15.2.1.b167 lib/msgr/consumer.rb
msgr-0.15.2.1.b166 lib/msgr/consumer.rb
msgr-0.15.2.1.b165 lib/msgr/consumer.rb
msgr-0.15.2.1.b164 lib/msgr/consumer.rb
msgr-0.15.2.1.b163 lib/msgr/consumer.rb
msgr-0.15.2.1.b162 lib/msgr/consumer.rb
msgr-0.15.2.1.b161 lib/msgr/consumer.rb
msgr-0.15.2.1.b160 lib/msgr/consumer.rb
msgr-0.15.2.1.b159 lib/msgr/consumer.rb
msgr-0.15.2.1.b158 lib/msgr/consumer.rb