module Ably::Modules::Encodeable::ClassMethods
Public Instance Methods
Return a Message or Presence object from the encoded JSON-like object, using the optional channel options @param message_object [Hash] JSON-like object representation of an encoded message @param channel_options [Hash] Channel options, currently reserved for Encryption options @yield [Ably::Exceptions::BaseAblyException] yields an Ably
exception if decoding fails @return [Message,Presence]
# File lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb, line 23 def from_encoded(message_object, channel_options = {}, &error_block) new(message_object).tap do |message| message.decode(encoders, channel_options, &error_block) end end
Return an Array of Message or Presence objects from the encoded Array of JSON-like objects, using the optional channel options @param message_object_array [Array<Hash>] Array of JSON-like objects with encoded messages @param channel_options [Hash] Channel options, currently reserved for Encryption options @return [Array<Message,Presence>]
# File lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb, line 33 def from_encoded_array(message_object_array, channel_options = {}) Array(message_object_array).map do |message_object| from_encoded(message_object, channel_options) end end
Register an encoder for this object @api private
# File lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb, line 41 def register_encoder(encoder, options = {}) encoders << Ably::Models::MessageEncoders.encoder_from(encoder, options) end
Private Instance Methods
# File lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb, line 46 def encoders @encoders ||= [] end