Class: Mimi::Messaging::Message
- Inherits:
-
Hash
- Object
- Hash
- Mimi::Messaging::Message
- Defined in:
- lib/mimi/messaging/message.rb
Overview
A Message is a Hash and additional headers structure.
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#initialize(message_or_hash, headers = nil) ⇒ Message
constructor
Creates a Message out of Hash or another Message.
Constructor Details
#initialize(message_or_hash, headers = nil) ⇒ Message
Creates a Message out of Hash or another Message.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/mimi/messaging/message.rb', line 16 def initialize(, headers = nil) unless .is_a?(Hash) # or a Message raise ArgumentError, "Message or Hash is expected as argument" end # copy attributes .each { |k, v| self[k] = v.dup } # copy headers headers ||= {} if .is_a?(Mimi::Messaging::Message) @headers = .headers.merge(headers) else @headers = headers end end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
9 10 11 |
# File 'lib/mimi/messaging/message.rb', line 9 def headers @headers end |