Class: Harbinger::Message
- Inherits:
-
Object
- Object
- Harbinger::Message
- Defined in:
- lib/harbinger/message.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
Instance Method Summary collapse
- #append(container, key, value) ⇒ Object
- #contexts ⇒ Object
-
#initialize {|_self| ... } ⇒ Message
constructor
A new instance of Message.
Constructor Details
#initialize {|_self| ... } ⇒ Message
Returns a new instance of Message.
4 5 6 7 |
# File 'lib/harbinger/message.rb', line 4 def initialize @attributes = {} yield(self) if block_given? end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
3 4 5 |
# File 'lib/harbinger/message.rb', line 3 def attributes @attributes end |
Instance Method Details
#append(container, key, value) ⇒ Object
9 10 11 12 13 |
# File 'lib/harbinger/message.rb', line 9 def append(container, key, value) composite_key = "#{container}.#{key}" @attributes[composite_key] ||= [] @attributes[composite_key] << value end |
#contexts ⇒ Object
15 16 17 |
# File 'lib/harbinger/message.rb', line 15 def contexts attributes.keys.collect { |key| key.split('.')[0] }.uniq end |