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.



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

def initialize(delivery_info, properties, payload)
  @delivery_info = delivery_info
  @properties    = properties
  @payload       = payload
  @body          = MultiJson.load(payload).with_indifferent_access
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



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

def body
  @body
end

#delivery_infoObject (readonly)

Returns the value of attribute delivery_info.



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

def delivery_info
  @delivery_info
end

#payloadObject (readonly)

Returns the value of attribute payload.



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

def payload
  @payload
end

#propertiesObject (readonly)

Returns the value of attribute properties.



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

def properties
  @properties
end

Instance Method Details

#to_sObject Also known as: inspect



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

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