Method: Moped::Protocol::Reply.deserialize

Defined in:
lib/moped/protocol/reply.rb

.deserialize(buffer) ⇒ Reply

Consumes a buffer, returning the deserialized Reply message.

reply from.

Examples:

socket = TCPSocket.new "localhost", 27017
socket.write Moped::Protocol::Command.new(:admin, ismaster: 1).serialize
reply = Moped::Protocol::Reply.deserialize(socket)
reply.documents[0]['ismaster'] # => 1

Parameters:

  • buffer (#read)

    an IO or IO-like resource to deserialize the

Returns:

  • (Reply)

    the deserialized reply



133
134
135
136
137
138
139
# File 'lib/moped/protocol/reply.rb', line 133

def deserialize(buffer)
  reply = allocate
  fields.each do |field|
    reply.__send__ :"deserialize_#{field}", buffer
  end
  reply
end