Class: MongoDbUtils::Model::Db
- Inherits:
-
Object
- Object
- MongoDbUtils::Model::Db
- Defined in:
- lib/mongo-db-utils/models/db.rb
Overview
A Db stored in the config
Direct Known Subclasses
Constant Summary collapse
- URI_NO_USER =
/mongodb:\/\/(.*)\/(.*$)/
- URI_USER =
/mongodb:\/\/(.*):(.*)@(.*)\/(.*$)/
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #authentication_required? ⇒ Boolean
- #host ⇒ Object
- #host_port ⇒ Object
-
#initialize(uri) ⇒ Db
constructor
A new instance of Db.
- #port ⇒ Object
-
#to_host_s ⇒ Object
Return the host string in a format that is compatable with mongo binary tools See: docs.mongodb.org/manual/reference/program/mongodump/#cmdoption-mongodump–host.
- #to_s ⇒ Object
- #to_s_simple ⇒ Object
Constructor Details
#initialize(uri) ⇒ Db
Returns a new instance of Db.
29 30 31 32 33 |
# File 'lib/mongo-db-utils/models/db.rb', line 29 def initialize(uri) @uri = uri host_port end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
27 28 29 |
# File 'lib/mongo-db-utils/models/db.rb', line 27 def name @name end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
27 28 29 |
# File 'lib/mongo-db-utils/models/db.rb', line 27 def password @password end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
27 28 29 |
# File 'lib/mongo-db-utils/models/db.rb', line 27 def uri @uri end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
27 28 29 |
# File 'lib/mongo-db-utils/models/db.rb', line 27 def username @username end |
Instance Method Details
#<=>(other) ⇒ Object
63 64 65 |
# File 'lib/mongo-db-utils/models/db.rb', line 63 def <=>(other) self.to_s <=> other.to_s end |
#authentication_required? ⇒ Boolean
35 36 37 |
# File 'lib/mongo-db-utils/models/db.rb', line 35 def authentication_required? has?(self.username) && has?(self.password) end |
#host ⇒ Object
39 40 41 |
# File 'lib/mongo-db-utils/models/db.rb', line 39 def host host_and_port[:host] end |
#host_port ⇒ Object
67 |
# File 'lib/mongo-db-utils/models/db.rb', line 67 def host_port; bits[:host_port]; end |
#port ⇒ Object
43 44 45 |
# File 'lib/mongo-db-utils/models/db.rb', line 43 def port host_and_port[:port] end |
#to_host_s ⇒ Object
Return the host string in a format that is compatable with mongo binary tools See: docs.mongodb.org/manual/reference/program/mongodump/#cmdoption-mongodump–host
51 52 53 |
# File 'lib/mongo-db-utils/models/db.rb', line 51 def to_host_s "#{host_port}" end |
#to_s ⇒ Object
59 60 61 |
# File 'lib/mongo-db-utils/models/db.rb', line 59 def to_s "[SingleDb-(#{to_host_s}/#{name})]" end |
#to_s_simple ⇒ Object
55 56 57 |
# File 'lib/mongo-db-utils/models/db.rb', line 55 def to_s_simple "#{name} on #{host_port} - (#{username}:#{password})" end |