Sha256: c1f2fae5e069eb503ef0dbeaf7814f641ec58510f1140b21e37ea240910ba7d3

Contents?: true

Size: 701 Bytes

Versions: 24

Compression:

Stored size: 701 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

24 entries across 24 versions & 1 rubygems

Version Path
msgr-0.15.2.1.b157 lib/msgr/consumer.rb
msgr-0.15.2.1.b156 lib/msgr/consumer.rb
msgr-0.15.2.1.b155 lib/msgr/consumer.rb
msgr-0.15.2.1.b154 lib/msgr/consumer.rb
msgr-0.15.2.1.b152 lib/msgr/consumer.rb
msgr-0.15.1.1.b151 lib/msgr/consumer.rb
msgr-0.15.2 lib/msgr/consumer.rb
msgr-0.15.1.1.b150 lib/msgr/consumer.rb
msgr-0.15.1.1.b146 lib/msgr/consumer.rb
msgr-0.15.1.1.b145 lib/msgr/consumer.rb
msgr-0.15.1.1.b144 lib/msgr/consumer.rb
msgr-0.15.1.1.b143 lib/msgr/consumer.rb
msgr-0.15.1.1.b141 lib/msgr/consumer.rb
msgr-0.15.0.1.b140 lib/msgr/consumer.rb
msgr-0.15.1 lib/msgr/consumer.rb
msgr-0.15.0.1.b139 lib/msgr/consumer.rb
msgr-0.15.0.1.b136 lib/msgr/consumer.rb
msgr-0.15.0.1.b135 lib/msgr/consumer.rb
msgr-0.15.0.1.b134 lib/msgr/consumer.rb
msgr-0.15.0.1.b131 lib/msgr/consumer.rb