Class: Mercury::ReceivedMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/mercury/received_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, metadata, is_ackable: false) ⇒ ReceivedMessage

Returns a new instance of ReceivedMessage.



5
6
7
8
9
# File 'lib/mercury/received_message.rb', line 5

def initialize(content, , is_ackable: false)
  @content = content
   = 
  @is_ackable = is_ackable
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def content
  @content
end

#metadataObject (readonly)

Returns the value of attribute metadata.



3
4
5
# File 'lib/mercury/received_message.rb', line 3

def 
  
end

Instance Method Details

#ackObject



19
20
21
22
# File 'lib/mercury/received_message.rb', line 19

def ack
  @is_ackable or raise 'This message is not ackable'
  .ack
end

#headersObject



15
16
17
# File 'lib/mercury/received_message.rb', line 15

def headers
  .headers || {}
end

#nackObject



29
30
31
32
# File 'lib/mercury/received_message.rb', line 29

def nack
  @is_ackable or raise 'This message is not nackable'
  .reject(requeue: true)
end

#rejectObject



24
25
26
27
# File 'lib/mercury/received_message.rb', line 24

def reject
  @is_ackable or raise 'This message is not rejectable'
  .reject(requeue: false)
end

#tagObject



11
12
13
# File 'lib/mercury/received_message.rb', line 11

def tag
  .routing_key
end