lib/ably/modules/encodeable.rb in ably-0.8.2 vs lib/ably/modules/encodeable.rb in ably-0.8.3

- old
+ new

@@ -33,12 +33,15 @@ raw_hash_object['encoding'] end private def decode_binary_data_before_to_json(message) - if message[:data].kind_of?(String) && message[:data].encoding == ::Encoding::ASCII_8BIT - message[:data] = ::Base64.encode64(message[:data]) - message[:encoding] = [message[:encoding], 'base64'].compact.join('/') + data_key = message[:data] ? :data : 'data' + encoding_key = message[:encoding] ? :encoding : 'encoding' + + if message[data_key].kind_of?(String) && message[data_key].encoding == ::Encoding::ASCII_8BIT + message[data_key] = ::Base64.encode64(message[data_key]) + message[encoding_key] = [message[encoding_key], 'base64'].compact.join('/') end end def apply_encoders(method, channel) max_encoding_length = 512