Class: Moped::Protocol::Reply
- Includes:
- Message
- Defined in:
- lib/moped/protocol/reply.rb
Overview
The Protocol class representing messages received from a mongo connection.
Constant Summary collapse
- UNAUTHORIZED =
10057
Instance Attribute Summary collapse
-
#count ⇒ Number
The number of documents returned.
-
#cursor_id ⇒ Number
The id of the cursor on the server.
-
#documents ⇒ Array
The returned documents.
-
#flags ⇒ Array<Symbol>
The flags for this reply.
-
#length ⇒ Number
The length of the message.
-
#offset ⇒ Number
The starting position within the cursor.
-
#op_code ⇒ Number
The operation code of this message (always 1).
-
#request_id ⇒ Number
The request id of the message.
-
#response_to ⇒ Number
The id that generated the message.
Class Method Summary collapse
-
.deserialize(buffer) ⇒ Reply
Consumes a buffer, returning the deserialized Reply message.
Instance Method Summary collapse
Methods included from Message
included, #inspect, #receive_replies, #serialize
Instance Attribute Details
#count ⇒ Number
Returns the number of documents returned.
50 |
# File 'lib/moped/protocol/reply.rb', line 50 int32 :count |
#cursor_id ⇒ Number
Returns the id of the cursor on the server.
42 |
# File 'lib/moped/protocol/reply.rb', line 42 int64 :cursor_id |
#documents ⇒ Array
Returns the returned documents.
54 |
# File 'lib/moped/protocol/reply.rb', line 54 document :documents, type: :array |
#flags ⇒ Array<Symbol>
Returns the flags for this reply.
36 37 38 |
# File 'lib/moped/protocol/reply.rb', line 36 flags :flags, cursor_not_found: 2 ** 0, query_failure: 2 ** 1, await_capable: 2 ** 3 |
#length ⇒ Number
Returns the length of the message.
20 |
# File 'lib/moped/protocol/reply.rb', line 20 int32 :length |
#offset ⇒ Number
Returns the starting position within the cursor.
46 |
# File 'lib/moped/protocol/reply.rb', line 46 int32 :offset |
#op_code ⇒ Number
Returns the operation code of this message (always 1).
32 |
# File 'lib/moped/protocol/reply.rb', line 32 int32 :op_code |
#request_id ⇒ Number
Returns the request id of the message.
24 |
# File 'lib/moped/protocol/reply.rb', line 24 int32 :request_id |
#response_to ⇒ Number
Returns the id that generated the message.
28 |
# File 'lib/moped/protocol/reply.rb', line 28 int32 :response_to |
Class Method Details
.deserialize(buffer) ⇒ Reply
Consumes a buffer, returning the deserialized Reply message.
reply from.
83 84 85 86 87 88 89 |
# File 'lib/moped/protocol/reply.rb', line 83 def deserialize(buffer) reply = allocate fields.each do |field| reply.__send__ :"deserialize_#{field}", buffer end reply end |
Instance Method Details
#cursor_not_found? ⇒ Boolean
58 59 60 |
# File 'lib/moped/protocol/reply.rb', line 58 def cursor_not_found? flags.include?(:cursor_not_found) end |
#query_failed? ⇒ Boolean
62 63 64 |
# File 'lib/moped/protocol/reply.rb', line 62 def query_failed? flags.include?(:query_failure) end |
#unauthorized? ⇒ Boolean
66 67 68 |
# File 'lib/moped/protocol/reply.rb', line 66 def documents.first["code"] == UNAUTHORIZED end |