Method: Mongo::Protocol::Compressed#maybe_inflate

Defined in:
lib/mongo/protocol/compressed.rb

#maybe_inflateProtocol::Message

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.

Inflates an OP_COMRESSED message and returns the original message.

Returns:

Since:

  • 2.5.0



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/mongo/protocol/compressed.rb', line 95

def maybe_inflate
  message = Registry.get(@original_op_code).allocate
  buf = decompress(@compressed_message)

  message.send(:fields).each do |field|
    if field[:multi]
      Message.deserialize_array(message, buf, field)
    else
      Message.deserialize_field(message, buf, field)
    end
  end
  if message.is_a?(Msg)
    message.fix_after_deserialization
  end
  message
end