Class: Announce::Message

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Message

Returns a new instance of Message.



8
9
10
11
12
13
14
# File 'lib/announce/message.rb', line 8

def initialize(options={})
  @options = {
    'message_id' => SecureRandom.uuid,
    'app' => app,
    'sent_at' => Time.now.utc
  }.merge(options).stringify_keys
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



6
7
8
# File 'lib/announce/message.rb', line 6

def options
  @options
end

Instance Method Details

#appObject



16
17
18
# File 'lib/announce/message.rb', line 16

def app
  Announce.options[:app_name]
end

#to_jsonObject



24
25
26
# File 'lib/announce/message.rb', line 24

def to_json
  options.to_json
end

#to_messageObject



20
21
22
# File 'lib/announce/message.rb', line 20

def to_message
  options.stringify_keys
end