Class: BBK::HTTP::MessageConsumer

Inherits:
Object
  • Object
show all
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

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

Returns:

  • (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

#protocolsObject



20
21
22
# File 'lib/bbk/http/message_consumer.rb', line 20

def protocols
  PROTOCOLS
end

#sync?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/bbk/http/message_consumer.rb', line 16

def sync?
  true
end