class Ably::Models::MessageEncoders::Utf8

Utf8 Encoder and Decoder Uses encoding identifier ‘utf-8’ and encodes all JSON objects as UTF-8, and sets the encoding when decoding

Constants

ENCODING_ID

Public Instance Methods

decode(message, channel_options) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/models/message_encoders/utf8.rb, line 14
def decode(message, channel_options)
  if is_utf8_encoded?(message)
    message[:data] = message[:data].force_encoding(Encoding::UTF_8)
    strip_current_encoding_part message
  end
end
encode(message, channel_options) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/models/message_encoders/utf8.rb, line 10
def encode(message, channel_options)
  # no encoding of UTF-8 required
end

Private Instance Methods

is_utf8_encoded?(message) click to toggle source
# File lib/submodules/ably-ruby/lib/ably/models/message_encoders/utf8.rb, line 22
def is_utf8_encoded?(message)
  current_encoding_part(message).to_s.match(/^#{ENCODING_ID}$/i)
end