RUBY-322 nicer inspect methods

This commit is contained in:
Kyle Banker 2011-09-01 11:42:56 -04:00
parent a916d3c8a2
commit e2178b0f1d
3 changed files with 15 additions and 2 deletions

View File

@ -147,6 +147,11 @@ module Mongo
setup(opts) setup(opts)
end end
def inspect
"<Mongo::ReplSetConnection:0x#{self.object_id.to_s(16)} @seeds=#{@seeds} " +
"@connected=#{@connected}>"
end
# Initiate a connection to the replica set. # Initiate a connection to the replica set.
def connect def connect
sync_synchronize(:EX) do sync_synchronize(:EX) do

View File

@ -1,7 +1,7 @@
module Mongo module Mongo
class Node class Node
attr_accessor :host, :port, :address, :config, :repl_set_status, :connection, :socket attr_accessor :host, :port, :address, :config, :connection, :socket
def initialize(connection, data) def initialize(connection, data)
self.connection = connection self.connection = connection
@ -21,7 +21,11 @@ module Mongo
alias :== :eql? alias :== :eql?
def host_string def host_string
"#{@host}:#{@port}" address
end
def inspect
"<Mongo::Node:0x#{self.object_id.to_s(16)} @host=#{@host} @port=#{@port}>"
end end
# Create a connection to the provided node, # Create a connection to the provided node,

View File

@ -11,6 +11,10 @@ module Mongo
@refresh_node = nil @refresh_node = nil
end end
def inspect
"<Mongo::PoolManager:0x#{self.object_id.to_s(16)} @seeds=#{@seeds}>"
end
def connect def connect
initialize_data initialize_data
members = connect_to_members members = connect_to_members