Class: Superbolt::IncomingMessage
- Inherits:
-
Object
- Object
- Superbolt::IncomingMessage
- Defined in:
- lib/superbolt/incoming_message.rb
Instance Attribute Summary collapse
-
#channel ⇒ Object
readonly
Returns the value of attribute channel.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
- #ack ⇒ Object
-
#initialize(delivery_info, payload, channel) ⇒ IncomingMessage
constructor
A new instance of IncomingMessage.
- #parse ⇒ Object
- #reject(requeue = true) ⇒ Object
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
#channel ⇒ Object (readonly)
Returns the value of attribute channel.
3 4 5 |
# File 'lib/superbolt/incoming_message.rb', line 3 def channel @channel end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
3 4 5 |
# File 'lib/superbolt/incoming_message.rb', line 3 def payload @payload end |
#tag ⇒ Object (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
#ack ⇒ Object
21 22 23 |
# File 'lib/superbolt/incoming_message.rb', line 21 def ack channel.acknowledge(tag) end |
#parse ⇒ Object
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 |