Sha256: 2903b6897c5df1bd6d8fe73585eeb1c69d4210f456245c74ffcf8360caa86f0c

Contents?: true

Size: 640 Bytes

Versions: 32

Compression:

Stored size: 640 Bytes

Contents

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
      raise Msgr::NoAction.new "No action `#{action}` for `#{self.class.name}`." unless respond_to? action

      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

32 entries across 32 versions & 1 rubygems

Version Path
msgr-0.9.0 lib/msgr/consumer.rb
msgr-0.8.0 lib/msgr/consumer.rb
msgr-0.7.0 lib/msgr/consumer.rb
msgr-0.6.0 lib/msgr/consumer.rb
msgr-0.5.0 lib/msgr/consumer.rb
msgr-0.4.1 lib/msgr/consumer.rb
msgr-0.4.0 lib/msgr/consumer.rb
msgr-0.3.0 lib/msgr/consumer.rb
msgr-0.2.1 lib/msgr/consumer.rb
msgr-0.2.0 lib/msgr/consumer.rb
msgr-0.1.1 lib/msgr/consumer.rb
msgr-0.1.0 lib/msgr/consumer.rb