Module: Ably::Modules::Encodeable::ClassMethods
- Defined in:
- lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb
Instance Method Summary collapse
-
#from_encoded(message_object, channel_options = {}) {|Ably::Exceptions::BaseAblyException| ... } ⇒ Message, Presence
Return a Message or Presence object from the encoded JSON-like object, using the optional channel options.
-
#from_encoded_array(message_object_array, channel_options = {}) ⇒ Array<Message,Presence>
Return an Array of Message or Presence objects from the encoded Array of JSON-like objects, using the optional channel options.
-
#register_encoder(encoder, options = {}) ⇒ Object
private
Register an encoder for this object.
Instance Method Details
#from_encoded(message_object, channel_options = {}) {|Ably::Exceptions::BaseAblyException| ... } ⇒ Message, Presence
Return a Message or Presence object from the encoded JSON-like object, using the optional channel options
23 24 25 26 27 |
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 23 def from_encoded(, = {}, &error_block) new().tap do || .decode(encoders, , &error_block) end end |
#from_encoded_array(message_object_array, channel_options = {}) ⇒ Array<Message,Presence>
Return an Array of Message or Presence objects from the encoded Array of JSON-like objects, using the optional channel options
33 34 35 36 37 |
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 33 def from_encoded_array(, = {}) Array().map do || from_encoded(, ) end end |
#register_encoder(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.
Register an encoder for this object
41 42 43 |
# File 'lib/submodules/ably-ruby/lib/ably/modules/encodeable.rb', line 41 def register_encoder(encoder, = {}) encoders << Ably::Models::MessageEncoders.encoder_from(encoder, ) end |