Module: Ably::Models::MessageEncoders

Extended by:
Ably::Modules::Conversions
Defined in:
lib/submodules/ably-ruby/lib/ably/models/message_encoders/base.rb,
lib/submodules/ably-ruby/lib/ably/models/message_encoders/json.rb,
lib/submodules/ably-ruby/lib/ably/models/message_encoders/utf8.rb,
lib/submodules/ably-ruby/lib/ably/models/message_encoders/base64.rb,
lib/submodules/ably-ruby/lib/ably/models/message_encoders/cipher.rb

Defined Under Namespace

Classes: Base, Base64, Cipher, Json, Utf8

Class Method Summary collapse

Class Method Details

.encoder_from(encoder, options) ⇒ Object

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.



116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/submodules/ably-ruby/lib/ably/models/message_encoders/base.rb', line 116

def self.encoder_from(encoder, options)
  encoder_klass = if encoder.kind_of?(String)
    encoder.split('::').inject(Kernel) do |base, klass_name|
      base.public_send(:const_get, klass_name)
    end
  else
    encoder
  end

  raise "Encoder must inherit from `Ably::Models::MessageEncoders::Base`" unless encoder_klass.ancestors.include?(Ably::Models::MessageEncoders::Base)
  encoder_klass.new(self, options)
end

.register_default_encoders(client, options = {}) ⇒ Object

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.



107
108
109
110
111
112
113
# File 'lib/submodules/ably-ruby/lib/ably/models/message_encoders/base.rb', line 107

def self.register_default_encoders(client, options = {})
  binary_protocol = !!options[:binary_protocol]
  client.register_encoder Ably::Models::MessageEncoders::Utf8
  client.register_encoder Ably::Models::MessageEncoders::Json
  client.register_encoder Ably::Models::MessageEncoders::Cipher
  client.register_encoder Ably::Models::MessageEncoders::Base64, binary_protocol: binary_protocol
end