Module: Ably::Modules::Encodeable

Included in:
Ably::Models::Message, Ably::Models::PresenceMessage, Ably::Models::ProtocolMessage
Defined in:
lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb

Overview

Provides methods to allow this model’s ‘data` property to be encoded and decoded based on the `encoding` property.

This module expects the following:

  • A #attributes method that returns the underlying hash object

  • A #set_attributes_object(attributes) method that updates the underlying hash object

  • A #raw_hash_object attribute that returns the original hash object used to create this object

Instance Method Summary collapse

Instance Method Details

#decode(channel) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Decode a message using the channel options and registered encoders for the client

Parameters:

  • channel (Ably::Realtime::Channel)


25
26
27
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 25

def decode(channel)
  apply_encoders :decode, channel
end

#encode(channel) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

This method returns an undefined value.

Encode a message using the channel options and register encoders for the client

Parameters:

  • channel (Ably::Realtime::Channel)


17
18
19
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 17

def encode(channel)
  apply_encoders :encode, channel
end

#original_encodingString?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The original encoding of this message when it was received as a raw message from the Ably service

Returns:

  • (String, nil)


32
33
34
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 32

def original_encoding
  raw_hash_object['encoding']
end