Fix for connecting to non-default port

This commit is contained in:
delano 2009-12-02 16:24:36 -05:00
parent 5995572a3e
commit 5bf512fb80

View File

@ -96,7 +96,7 @@ module Mongo
# :right => ["db2.example.com", 27017]}, nil, # :right => ["db2.example.com", 27017]}, nil,
# :pool_size => 20, :timeout => 5) # :pool_size => 20, :timeout => 5)
def initialize(pair_or_host=nil, port=nil, options={}) def initialize(pair_or_host=nil, port=nil, options={})
@nodes = format_pair(pair_or_host) @nodes = format_pair(pair_or_host, port)
# Host and port of current master. # Host and port of current master.
@host = @port = nil @host = @port = nil
@ -524,7 +524,7 @@ module Mongo
## Private helper methods ## Private helper methods
# Returns an array of host-port pairs. # Returns an array of host-port pairs.
def format_pair(pair_or_host) def format_pair(pair_or_host, port)
case pair_or_host case pair_or_host
when String when String
[[pair_or_host, port ? port.to_i : DEFAULT_PORT]] [[pair_or_host, port ? port.to_i : DEFAULT_PORT]]