Class: ReliableMsg::Message
- Inherits:
-
Object
- Object
- ReliableMsg::Message
- Defined in:
- lib/reliable-msg/client.rb
Overview
Retrieved Message
Returned from Queue.get holding the last message retrieved from the queue and providing access to the message identifier, headers and object.
For example:
while queue.get do |msg|
print "Message #{msg.id}"
print "Headers: #{msg[:created]}"
print "Headers: #{msg.headers.inspect}"
print msg.object
true
end
Instance Method Summary collapse
-
#[](symbol) ⇒ Object
Returns the message header.
-
#headers ⇒ Object
Returns the message headers.
-
#id ⇒ Object
Returns the message identifier.
-
#initialize(id, headers, object) ⇒ Message
constructor
:nodoc:.
-
#object ⇒ Object
Returns the message object.
Constructor Details
#initialize(id, headers, object) ⇒ Message
:nodoc:
164 165 166 |
# File 'lib/reliable-msg/client.rb', line 164 def initialize id, headers, object # :nodoc: @id, @object, @headers = id, object, headers end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object (private)
205 206 207 208 |
# File 'lib/reliable-msg/client.rb', line 205 def method_missing symbol, *args, &block raise ArgumentError, "Wrong number of arguments (#{args.length} for 0)" unless args.empty? @headers[symbol] end |
Instance Method Details
#[](symbol) ⇒ Object
Returns the message header.
:call-seq:
msg[symbol] -> obj
200 201 202 |
# File 'lib/reliable-msg/client.rb', line 200 def [] symbol @headers[symbol] end |
#headers ⇒ Object
Returns the message headers.
:call-seq:
msg.headers -> hash
191 192 193 |
# File 'lib/reliable-msg/client.rb', line 191 def headers @headers end |
#id ⇒ Object
Returns the message identifier.
:call-seq:
msg.id -> id
173 174 175 |
# File 'lib/reliable-msg/client.rb', line 173 def id @id end |
#object ⇒ Object
Returns the message object.
:call-seq:
msg.object -> obj
182 183 184 |
# File 'lib/reliable-msg/client.rb', line 182 def object @object end |