Class: MongoDbUtils::Model::ReplicaSetDb
- Defined in:
- lib/mongo-db-utils/models/db.rb
Constant Summary
Constants inherited from Db
Instance Attribute Summary collapse
-
#set_name ⇒ Object
readonly
Returns the value of attribute set_name.
Attributes inherited from Db
#name, #password, #uri, #username
Instance Method Summary collapse
-
#host ⇒ Object
Block usage of this method from the super.
-
#hosts ⇒ Object
Return an array of host:port strings.
-
#initialize(uri, name) ⇒ ReplicaSetDb
constructor
A new instance of ReplicaSetDb.
-
#port ⇒ Object
Block usage of this method from the super.
-
#to_host_s ⇒ Object
Note: we override this to provide a replica set format.
- #to_s ⇒ Object
Methods inherited from Db
#<=>, #authentication_required?, #host_port, #to_s_simple
Constructor Details
#initialize(uri, name) ⇒ ReplicaSetDb
Returns a new instance of ReplicaSetDb.
112 113 114 115 |
# File 'lib/mongo-db-utils/models/db.rb', line 112 def initialize(uri, name) super(uri) @set_name = name end |
Instance Attribute Details
#set_name ⇒ Object (readonly)
Returns the value of attribute set_name.
111 112 113 |
# File 'lib/mongo-db-utils/models/db.rb', line 111 def set_name @set_name end |
Instance Method Details
#host ⇒ Object
Block usage of this method from the super
124 125 126 |
# File 'lib/mongo-db-utils/models/db.rb', line 124 def host raise "'host' is not a valid method for a ReplicaSetDb - use 'hosts' instead." end |
#hosts ⇒ Object
Return an array of host:port strings
119 120 121 |
# File 'lib/mongo-db-utils/models/db.rb', line 119 def hosts host_port.split(",") end |
#port ⇒ Object
Block usage of this method from the super
129 130 131 |
# File 'lib/mongo-db-utils/models/db.rb', line 129 def port raise "'port' is not a valid method for a ReplicaSetDb - use 'hosts' instead." end |
#to_host_s ⇒ Object
Note: we override this to provide a replica set format
134 135 136 |
# File 'lib/mongo-db-utils/models/db.rb', line 134 def to_host_s "#{@set_name}/#{host_port}" end |
#to_s ⇒ Object
138 139 140 |
# File 'lib/mongo-db-utils/models/db.rb', line 138 def to_s "[ReplicaSetDb-(#{to_host_s}/#{name})]" end |