Class: Freddy::MessageHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/freddy/message_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(adapter, delivery) ⇒ MessageHandler

Returns a new instance of MessageHandler.



5
6
7
8
9
10
# File 'lib/freddy/message_handler.rb', line 5

def initialize(adapter, delivery)
  @adapter = adapter
  @properties = delivery.properties
  @destination = @properties[:destination]
  @correlation_id = @properties[:correlation_id]
end

Instance Attribute Details

#correlation_idObject (readonly)

Returns the value of attribute correlation_id.



3
4
5
# File 'lib/freddy/message_handler.rb', line 3

def correlation_id
  @correlation_id
end

#destinationObject (readonly)

Returns the value of attribute destination.



3
4
5
# File 'lib/freddy/message_handler.rb', line 3

def destination
  @destination
end

Instance Method Details

#error(error = {error: "Couldn't process message"}) ⇒ Object



16
17
18
# File 'lib/freddy/message_handler.rb', line 16

def error(error = {error: "Couldn't process message"})
  @adapter.error(@properties[:reply_to], error)
end

#success(response = nil) ⇒ Object



12
13
14
# File 'lib/freddy/message_handler.rb', line 12

def success(response = nil)
  @adapter.success(@properties[:reply_to], response)
end