Class: Mongo::Configure::URI
- Inherits:
-
Struct
- Object
- Struct
- Mongo::Configure::URI
- Defined in:
- lib/mongo/configure/uri.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
Returns the value of attribute database.
-
#host ⇒ Object
Returns the value of attribute host.
-
#password ⇒ Object
Returns the value of attribute password.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
Returns the value of attribute scheme.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #auth ⇒ Object
-
#initialize(scheme = 'mongodb', host = 'localhost', port = '27017', database = '', user = nil, password = nil) ⇒ URI
constructor
A new instance of URI.
- #to_s ⇒ Object
Constructor Details
#initialize(scheme = 'mongodb', host = 'localhost', port = '27017', database = '', user = nil, password = nil) ⇒ URI
Returns a new instance of URI.
4 5 6 |
# File 'lib/mongo/configure/uri.rb', line 4 def initialize(scheme='mongodb',host='localhost',port='27017',database='',user=nil,password=nil) super end |
Instance Attribute Details
#database ⇒ Object
Returns the value of attribute database
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def database @database end |
#host ⇒ Object
Returns the value of attribute host
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def host @host end |
#password ⇒ Object
Returns the value of attribute password
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def password @password end |
#port ⇒ Object
Returns the value of attribute port
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def port @port end |
#scheme ⇒ Object
Returns the value of attribute scheme
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def scheme @scheme end |
#user ⇒ Object
Returns the value of attribute user
3 4 5 |
# File 'lib/mongo/configure/uri.rb', line 3 def user @user end |
Class Method Details
.parse(string) ⇒ Object
8 9 10 11 |
# File 'lib/mongo/configure/uri.rb', line 8 def self.parse(string) uri = ::URI.parse string new uri.scheme, uri.host, uri.port.to_s, uri.path.gsub(/^\//,''), uri.user, uri.password end |
Instance Method Details
#auth ⇒ Object
12 13 14 15 16 17 18 |
# File 'lib/mongo/configure/uri.rb', line 12 def auth if user || password [user,password].join(':')+'@' else '' end end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/mongo/configure/uri.rb', line 19 def to_s "#{scheme}://#{auth}#{host}:#{port}/#{database}" end |