Class: BBK::HTTP::MessageConsumer
- Inherits:
-
Object
- Object
- BBK::HTTP::MessageConsumer
- Defined in:
- lib/bbk/http/message_consumer.rb
Overview
MessageConsumer is partial consumer like object with ack and nack methods. Used for initialize HTTP message
Constant Summary collapse
- PROTOCOLS =
%w[http https].freeze
Instance Method Summary collapse
- #ack(incoming, *args, answer: nil, **kwargs) ⇒ Object
- #answered? ⇒ Boolean
-
#initialize(ack_action, nack_action) ⇒ MessageConsumer
constructor
A new instance of MessageConsumer.
- #nack(*args, **kwargs) ⇒ Object
- #protocols ⇒ Object
- #sync? ⇒ Boolean
Constructor Details
#initialize(ack_action, nack_action) ⇒ MessageConsumer
Returns a new instance of MessageConsumer.
10 11 12 13 14 |
# File 'lib/bbk/http/message_consumer.rb', line 10 def initialize(ack_action, nack_action) @ack_action = ack_action @nack_action = nack_action @answered = false end |
Instance Method Details
#ack(incoming, *args, answer: nil, **kwargs) ⇒ Object
24 25 26 27 |
# File 'lib/bbk/http/message_consumer.rb', line 24 def ack(incoming, *args, answer: nil, **kwargs) @answered = true unless answer.nil? @ack_action.call(incoming, *args, answer: answer, **kwargs) end |
#answered? ⇒ Boolean
33 34 35 |
# File 'lib/bbk/http/message_consumer.rb', line 33 def answered? @answered end |
#nack(*args, **kwargs) ⇒ Object
29 30 31 |
# File 'lib/bbk/http/message_consumer.rb', line 29 def nack(*args, **kwargs) @nack_action.call(*args, **kwargs) end |
#protocols ⇒ Object
20 21 22 |
# File 'lib/bbk/http/message_consumer.rb', line 20 def protocols PROTOCOLS end |
#sync? ⇒ Boolean
16 17 18 |
# File 'lib/bbk/http/message_consumer.rb', line 16 def sync? true end |