lib/submodules/ably-ruby/lib/ably/models/presence_message.rb in ably-rest-0.8.2 vs lib/submodules/ably-ruby/lib/ably/models/presence_message.rb in ably-rest-0.8.3
- old
+ new
@@ -107,14 +107,20 @@
# Return a JSON ready object from the underlying #hash using Ably naming conventions for keys
def as_json(*args)
hash.dup.tap do |presence_message|
presence_message['action'] = action.to_i
- decode_binary_data_before_to_json presence_message
- end.as_json
+ end.as_json.reject { |key, val| val.nil? }
rescue KeyError
raise KeyError, ':action is missing or invalid, cannot generate a valid Hash for ProtocolMessage'
end
+
+ def to_json(*args)
+ as_json(*args).tap do |presence_message|
+ decode_binary_data_before_to_json presence_message
+ end.to_json
+ end
+
# Assign this presence message to a ProtocolMessage before delivery to the Ably system
# @api private
def assign_to_protocol_message(protocol_message)
@protocol_message = protocol_message