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) ⇒ Message

Returns a new instance of Message.



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

def initialize(delivery_info, properties, payload)
  @delivery_info = delivery_info
  @properties    = properties
  @payload       = payload
  @body          = MultiJson.load(payload, symbolize_keys: true)
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info.



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

def delivery_info
  @delivery_info
end

#payloadObject (readonly)

Returns the value of attribute payload.



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

def payload
  @payload
end

#propertiesObject (readonly)

Returns the value of attribute properties.



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

def properties
  @properties
end

Instance Method Details

#to_sObject Also known as: inspect



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

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