Sha256: 78428f5e7a776a1a5ee15530ef4987236c7384b278db6ce863096ea3213709a2

Contents?: true

Size: 1.01 KB

Versions: 8

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

module Basquiat
  module Adapters
    # The simplest Message class. It's encouraged to tailor it to your adapter needs (hence BaseMessage).
    class BaseMessage < SimpleDelegator
      attr_reader :action

      # @param message [Object] It's assumed that message is some kind of JSON
      # @note All unknown messages will be delegated to the resulting Hash
      def initialize(message)
        @message = Basquiat::Json.decode(message)
        super(@message)
        @action = :ack
      end

      # @!group Action Setters
      # Sets the action to be taken after processing to be an ack.
      # Here just in case as the default is to acknowledge the message.
      def ack
        @action = :ack
      end

      # Sets the action to be taken after processing to be an nack / reject
      def nack
        @action = :nack
      end

      # Sets the action to be taken after processing to be a requeue
      def requeue
        @action = :requeue
      end
      # @!endgroup
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
basquiat-1.6.0 lib/basquiat/adapters/base_message.rb
basquiat-1.5.2 lib/basquiat/adapters/base_message.rb
basquiat-1.5.1 lib/basquiat/adapters/base_message.rb
basquiat-1.5.0 lib/basquiat/adapters/base_message.rb
basquiat-1.4.0 lib/basquiat/adapters/base_message.rb
basquiat-1.3.6 lib/basquiat/adapters/base_message.rb
basquiat-1.3.5 lib/basquiat/adapters/base_message.rb
basquiat-1.3.4 lib/basquiat/adapters/base_message.rb