Module: Ably::Modules::Encodeable
- Defined in:
- 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
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
-
#decode(encoders, channel_options, &error_block) ⇒ void
private
Decode a message using the channel options and registered encoders for the client.
-
#encode(encoders, channel_options, &error_block) ⇒ void
private
Encode a message using the channel options and register encoders for the client.
-
#original_encoding ⇒ String?
private
The original encoding of this message when it was received as a raw message from the Ably service.
Class Method Details
.included(base) ⇒ Object
13 14 15 |
# File 'lib/ably/modules/encodeable.rb', line 13 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#decode(encoders, channel_options, &error_block) ⇒ 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
65 66 67 |
# File 'lib/ably/modules/encodeable.rb', line 65 def decode(encoders, , &error_block) apply_encoders :decode, encoders, , &error_block end |
#encode(encoders, channel_options, &error_block) ⇒ 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
56 57 58 |
# File 'lib/ably/modules/encodeable.rb', line 56 def encode(encoders, , &error_block) apply_encoders :encode, encoders, , &error_block end |
#original_encoding ⇒ String?
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
72 73 74 |
# File 'lib/ably/modules/encodeable.rb', line 72 def original_encoding raw_hash_object['encoding'] end |