lib/submodules/ably-ruby/lib/ably/models/message.rb in ably-rest-0.9.3 vs lib/submodules/ably-ruby/lib/ably/models/message.rb in ably-rest-1.0.0

- old
+ new

@@ -122,20 +122,31 @@ def protocol_message raise RuntimeError, 'Message is not yet published with a ProtocolMessage. ProtocolMessage is nil' if @protocol_message.nil? @protocol_message end + # Contains any arbitrary key value pairs which may also contain other primitive JSON types, JSON-encodable objects or JSON-encodable arrays. + # The extras field is provided to contain message metadata and/or ancillary payloads in support of specific functionality, e.g. push + # @api private + def extras + attributes[:extras].tap do |val| + unless val.kind_of?(IdiomaticRubyWrapper) || val.kind_of?(Array) || val.kind_of?(Hash) || val.nil? + raise ArgumentError, "extras contains an unsupported type #{val.class}" + end + end + end + private def raw_hash_object @raw_hash_object end def protocol_message_index protocol_message.messages.map(&:object_id).index(self.object_id) end def set_attributes_object(new_attributes) - @attributes = IdiomaticRubyWrapper(new_attributes.clone.freeze, stop_at: [:data]) + @attributes = IdiomaticRubyWrapper(new_attributes.clone.freeze, stop_at: [:data, :extras]) end def logger return @logger if @logger protocol_message.logger if protocol_message