def connection_options
opts = {}
if @wtimeout
warn "Using wtimeout in a URI is deprecated, please use wtimeoutMS. It will be removed in v2.0."
opts[:wtimeout] = @wtimeout
end
opts[:wtimeout] = @wtimeoutms
opts[:w] = 1 if @safe
opts[:w] = @w if @w
opts[:j] = @journal
opts[:fsync] = @fsync
if @connecttimeoutms
opts[:connect_timeout] = @connecttimeoutms
end
if @sockettimeoutms
opts[:op_timeout] = @sockettimeoutms
end
if @pool_size
opts[:pool_size] = @pool_size
end
if @readpreference && replicaset?
opts[:read] = @readpreference
end
if @slaveok && !@readpreference
if direct?
opts[:slave_ok] = true
else
opts[:read] = :secondary_preferred
end
end
opts[:ssl] = @ssl
if direct?
opts[:auths] = auths
end
if replicaset.is_a?(String)
opts[:name] = replicaset
end
opts[:connect] = connect?
opts
end