Class: Ably::Rest::Models::Message

Inherits:
Object
  • Object
show all
Includes:
Modules::Conversions
Defined in:
lib/ably/rest/models/message.rb

Overview

A Message object encapsulates an individual message published in Ably retrieved via Rest

Instance Method Summary collapse

Constructor Details

#initialize(message) ⇒ Message

Returns a new instance of Message.



6
7
8
# File 'lib/ably/rest/models/message.rb', line 6

def initialize(message)
  @message = IdiomaticRubyWrapper(message.clone.freeze)
end

Instance Method Details

#==(other) ⇒ Object



59
60
61
62
# File 'lib/ably/rest/models/message.rb', line 59

def ==(other)
  other.kind_of?(Message) &&
    json == other.json
end

#[](key) ⇒ Object

Provide a normal Hash accessor to the underlying raw message object

Returns:

  • (Object)


48
49
50
# File 'lib/ably/rest/models/message.rb', line 48

def [](key)
  json[key]
end

#client_idString

Client ID of the publisher of the message

Returns:

  • (String)


27
28
29
# File 'lib/ably/rest/models/message.rb', line 27

def client_id
  json[:client_id]
end

#dataObject

Payload

Returns:

  • (Object)


20
21
22
# File 'lib/ably/rest/models/message.rb', line 20

def data
  json[:data]
end

#jsonHash

Raw message object

Returns:

  • (Hash)


55
56
57
# File 'lib/ably/rest/models/message.rb', line 55

def json
  @message
end

#message_idString

Unique message ID

Returns:

  • (String)


41
42
43
# File 'lib/ably/rest/models/message.rb', line 41

def message_id
  json[:message_id]
end

#nameString

Event name

Returns:

  • (String)


13
14
15
# File 'lib/ably/rest/models/message.rb', line 13

def name
  json[:name]
end

#sender_timestampTime

Timestamp when message was sent. This property is populated by the sender.

Returns:

  • (Time)


34
35
36
# File 'lib/ably/rest/models/message.rb', line 34

def sender_timestamp
  as_time_from_epoch(json[:timestamp]) if json[:timestamp]
end