Class | Moped::Uri |
In: |
lib/moped/uri.rb
|
Parent: | Object |
Parses MongoDB uri
@since 1.3.0
SCHEME | = | /(mongodb:\/\/)/ |
Get the scheme pattern.
@since 1.3.0 |
|
USER | = | /([-.\w:]+)/ |
The user name pattern.
@since 1.3.0 |
|
PASS | = | /([^@,]+)/ |
The password pattern.
@since 1.3.0 |
|
NODES | = | /((([-.\w]+)(?::(\w+))?,?)+)/ |
The nodes pattern.
@since 1.3.0 |
|
DATABASE | = | /(?:\/([-\w]+))?/ |
The database pattern.
@since 1.3.0 |
|
OPTIONS | = | /(?:\?(.+))/ |
The options pattern.
@since 1.3.0 |
|
URI | = | /#{SCHEME}(#{USER}:#{PASS}@)?#{NODES}#{DATABASE}#{OPTIONS}?/ |
The full URI pattern.
@since 1.3.0 |
|
WRITE_OPTIONS | = | [ "w", "j", "fsync", "wtimeout" ].freeze |
The options that have to do with write
concerns.
@since 2.0.0 |
|
READ_MAPPINGS | = | { "nearest" => :nearest, "primary" => :primary, "primarypreferred" => :primary_preferred, "secondary" => :secondary, "secondarypreferred" => :secondary_preferred |
The mappings from read preferences in the URI to Moped‘s.
@since 2.0.0 |
match | [R] |
@!attribute match
@return [ Array ] The uri match. |
Helper to determine if authentication is provided
@example Boolean response if username/password given
uri.auth_provided?
@return [ true, false ] If authorization is provided.
@since 1.3.0
Raise a human readable error when improper URI provided
@example Raise error and provide guidance on invalid URI
MongoUri.invalid!(uri)
@param [ String ] Invalid string
@since 1.3.1
Create Moped usable arguments
@example Get the moped args
uri.moped_arguments
@return [ Array ] Array of arguments usable by Moped
@since 1.3.0
Get the options provided in the URI.
@example Get the options
uri.options
@note The options provided in the URI string must match the MongoDB
specification.
@return [ Hash ] Options hash usable by Moped
@see docs.mongodb.org/manual/reference/connection-string/#connections-connection-options
@since 1.3.0
Get the uri as a Mongoid friendly configuration hash.
@example Get the uri as a hash.
uri.to_hash
@return [ Hash ] The uri as options.
@since 1.3.0