Class: Hutch::Message

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/hutch/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(delivery_info, properties, payload, serializer) ⇒ Message

Returns a new instance of Message.



9
10
11
12
13
14
# File 'lib/hutch/message.rb', line 9

def initialize(delivery_info, properties, payload, serializer)
  @delivery_info = delivery_info
  @properties    = properties
  @payload       = payload
  @body          = serializer.decode(payload)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



20
21
22
# File 'lib/hutch/message.rb', line 20

def body
  @body
end

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info.



7
8
9
# File 'lib/hutch/message.rb', line 7

def delivery_info
  @delivery_info
end

#payloadObject (readonly)

Returns the value of attribute payload.



7
8
9
# File 'lib/hutch/message.rb', line 7

def payload
  @payload
end

#propertiesObject (readonly)

Returns the value of attribute properties.



7
8
9
# File 'lib/hutch/message.rb', line 7

def properties
  @properties
end

Instance Method Details

#to_sObject Also known as: inspect



22
23
24
25
26
# File 'lib/hutch/message.rb', line 22

def to_s
  attrs = { :@body => body.to_s, message_id: message_id,
            timestamp: timestamp, routing_key: routing_key }
  "#<Message #{attrs.map { |k,v| "#{k}=#{v.inspect}" }.join(', ')}>"
end