Class: BBK::HTTP::Message
- Inherits:
-
Object
- Object
- BBK::HTTP::Message
- Defined in:
- lib/bbk/http/message.rb
Instance Attribute Summary collapse
-
#consumer ⇒ Object
readonly
Returns the value of attribute consumer.
-
#delivery_info ⇒ Object
readonly
Returns the value of attribute delivery_info.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#payload ⇒ Object
(also: #body)
readonly
Returns the value of attribute payload.
Instance Method Summary collapse
- #ack(*args, answer: nil, **kwargs) ⇒ Object
- #clone ⇒ Object
-
#initialize(consumer, headers, payload, delivery_info: {}, protocol: nil) ⇒ Message
constructor
A new instance of Message.
- #message_id ⇒ Object
- #nack(*args, error: nil, **kwargs) ⇒ Object
- #protocol ⇒ Object
- #reply_to ⇒ Object
- #user_id ⇒ Object
Constructor Details
#initialize(consumer, headers, payload, delivery_info: {}, protocol: nil) ⇒ Message
Returns a new instance of Message.
10 11 12 13 14 15 16 17 |
# File 'lib/bbk/http/message.rb', line 10 def initialize(consumer, headers, payload, delivery_info: {}, protocol: nil) @consumer = consumer @headers = headers.with_indifferent_access @payload = payload @payload = @payload.with_indifferent_access if @payload.is_a?(Hash) @delivery_info = delivery_info @protocol = protocol end |
Instance Attribute Details
#consumer ⇒ Object (readonly)
Returns the value of attribute consumer.
7 8 9 |
# File 'lib/bbk/http/message.rb', line 7 def consumer @consumer end |
#delivery_info ⇒ Object (readonly)
Returns the value of attribute delivery_info.
7 8 9 |
# File 'lib/bbk/http/message.rb', line 7 def delivery_info @delivery_info end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
7 8 9 |
# File 'lib/bbk/http/message.rb', line 7 def headers @headers end |
#payload ⇒ Object (readonly) Also known as: body
Returns the value of attribute payload.
7 8 9 |
# File 'lib/bbk/http/message.rb', line 7 def payload @payload end |
Instance Method Details
#ack(*args, answer: nil, **kwargs) ⇒ Object
35 36 37 |
# File 'lib/bbk/http/message.rb', line 35 def ack(*args, answer: nil, **kwargs) consumer.ack(self, *args, answer: answer, **kwargs) end |
#clone ⇒ Object
43 44 45 |
# File 'lib/bbk/http/message.rb', line 43 def clone self.class.new(@consumer, headers, payload, protocol: @protocol) end |
#message_id ⇒ Object
19 20 21 |
# File 'lib/bbk/http/message.rb', line 19 def headers[:message_id] end |
#nack(*args, error: nil, **kwargs) ⇒ Object
39 40 41 |
# File 'lib/bbk/http/message.rb', line 39 def nack(*args, error: nil, **kwargs) consumer.nack(self, *args, error: error, **kwargs) end |
#protocol ⇒ Object
31 32 33 |
# File 'lib/bbk/http/message.rb', line 31 def protocol @protocol.presence || @consumer&.protocols&.first end |
#reply_to ⇒ Object
23 24 25 |
# File 'lib/bbk/http/message.rb', line 23 def reply_to headers[:reply_to] end |
#user_id ⇒ Object
27 28 29 |
# File 'lib/bbk/http/message.rb', line 27 def user_id headers[:user_id] end |