Class: Superbolt::IncomingMessage

Inherits:
Object
  • Object
show all
Defined in:
lib/superbolt/incoming_message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delivery_info, payload, channel) ⇒ IncomingMessage

Returns a new instance of IncomingMessage.



5
6
7
8
9
# File 'lib/superbolt/incoming_message.rb', line 5

def initialize(delivery_info, payload, channel)
  @payload = payload
  @tag = delivery_info.delivery_tag if delivery_info
  @channel = channel
end

Instance Attribute Details

#channelObject (readonly)

Returns the value of attribute channel.



3
4
5
# File 'lib/superbolt/incoming_message.rb', line 3

def channel
  @channel
end

#payloadObject (readonly)

Returns the value of attribute payload.



3
4
5
# File 'lib/superbolt/incoming_message.rb', line 3

def payload
  @payload
end

#tagObject (readonly)

Returns the value of attribute tag.



3
4
5
# File 'lib/superbolt/incoming_message.rb', line 3

def tag
  @tag
end

Instance Method Details

#ackObject



21
22
23
# File 'lib/superbolt/incoming_message.rb', line 21

def ack
  channel.acknowledge(tag)
end

#parseObject



11
12
13
14
15
# File 'lib/superbolt/incoming_message.rb', line 11

def parse
  JSON.parse(payload)
rescue JSON::ParserError
  payload
end

#reject(requeue = true) ⇒ Object



17
18
19
# File 'lib/superbolt/incoming_message.rb', line 17

def reject(requeue=true)
  channel.reject(tag, requeue)
end