Class: Basquiat::Adapters::BaseMessage

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/basquiat/adapters/base_message.rb

Overview

The simplest Message class. It’s encouraged to tailor it to your adapter needs (hence BaseMessage).

Direct Known Subclasses

RabbitMq::Message

Instance Attribute Summary collapse

Action Setters collapse

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ BaseMessage

Note:

All unknown messages will be delegated to the resulting Hash

Returns a new instance of BaseMessage.

Parameters:

  • message (Object)

    It’s assumed that message is some kind of JSON



11
12
13
14
15
# File 'lib/basquiat/adapters/base_message.rb', line 11

def initialize(message)
  @message = Basquiat::Json.decode(message)
  super(@message)
  @action = :ack
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



7
8
9
# File 'lib/basquiat/adapters/base_message.rb', line 7

def action
  @action
end

Instance Method Details

#ackObject

Sets the action to be taken after processing to be an ack. Here just in case as the default is to acknowledge the message.



20
21
22
# File 'lib/basquiat/adapters/base_message.rb', line 20

def ack
  @action = :ack
end

#nackObject

Sets the action to be taken after processing to be an nack / reject



25
26
27
# File 'lib/basquiat/adapters/base_message.rb', line 25

def nack
  @action = :nack
end

#requeueObject

Sets the action to be taken after processing to be a requeue



30
31
32
# File 'lib/basquiat/adapters/base_message.rb', line 30

def requeue
  @action = :requeue
end