minor: nicer query opts generation

This commit is contained in:
Kyle Banker 2010-07-09 16:15:36 -04:00
parent 0460491863
commit 030c850669
1 changed files with 5 additions and 4 deletions

View File

@ -255,10 +255,11 @@ module Mongo
# @see http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-Mongo::Constants::OPQUERY # @see http://www.mongodb.org/display/DOCS/Mongo+Wire+Protocol#MongoWireProtocol-Mongo::Constants::OPQUERY
# The MongoDB wire protocol. # The MongoDB wire protocol.
def query_opts def query_opts
timeout = @timeout ? 0 : Mongo::Constants::OP_QUERY_NO_CURSOR_TIMEOUT opts = 0
slave_ok = @connection.slave_ok? ? Mongo::Constants::OP_QUERY_SLAVE_OK : 0 opts |= Mongo::Constants::OP_QUERY_NO_CURSOR_TIMEOUT unless @timeout
tailable = @tailable ? Mongo::Constants::OP_QUERY_TAILABLE : 0 opts |= Mongo::Constants::OP_QUERY_SLAVE_OK if @connection.slave_ok?
slave_ok + timeout + tailable opts |= Mongo::Constants::OP_QUERY_TAILABLE if @tailable
opts
end end
# Get the query options for this Cursor. # Get the query options for this Cursor.