lib/moped/protocol/reply.rb in moped-1.2.1 vs lib/moped/protocol/reply.rb in moped-1.2.2
- old
+ new
@@ -11,10 +11,12 @@
# reply = Moped::Protocol::Reply.deserialize(socket)
# reply.documents[0]["version"] # => "2.0.0"
class Reply
include Message
+ UNAUTHORIZED = 10057
+
# @attribute
# @return [Number] the length of the message
int32 :length
# @attribute
@@ -50,9 +52,21 @@
# @attribute
# @return [Array] the returned documents
document :documents, type: :array
finalize
+
+ def cursor_not_found?
+ flags.include?(:cursor_not_found)
+ end
+
+ def query_failed?
+ flags.include?(:query_failure)
+ end
+
+ def unauthorized?
+ documents.first["code"] == UNAUTHORIZED
+ end
class << self
# Consumes a buffer, returning the deserialized Reply message.
#