Class: Harbinger::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/harbinger/message.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Message

Returns a new instance of Message.

Yields:

  • (_self)

Yield Parameters:



4
5
6
7
# File 'lib/harbinger/message.rb', line 4

def initialize
  @attributes = {}
  yield(self) if block_given?
end

Instance Attribute Details

#attributesObject (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

#contextsObject



15
16
17
# File 'lib/harbinger/message.rb', line 15

def contexts
  attributes.keys.collect { |key| key.split('.')[0] }.uniq
end