You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# URI in the form mongodb://host:port/db/collection
126
-
# @option options [String, #to_s] :title (nil)
127
-
# @option options [String] :host
128
-
# @option options [Integer] :port
129
-
# @option options [String] :db ('quadb')
130
-
# @option options [String] :user for authentication
131
-
# @option options [String] :password for authentication
132
-
# @option options [String] :collection ('quads')
121
+
# @overload initialize(options = {}, &block)
122
+
# @param [Hash{Symbol => Object}] options
123
+
# @option options [String, #to_s] :title (nil)
124
+
# @option options [URI, #to_s] :uri (nil)
125
+
# URI in the form `mongodb://host:port/db`. The URI should also identify the collection use, but appending a `collection` path component such as `mongodb://host:port/db/collection`, this ensures that the collection will be maintained if cloned. See [Mongo::Client options](https://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial-2-0/#uri-options-conversions) for more information on Mongo URIs.
126
+
#
127
+
# @overload initialize(options = {}, &block)
128
+
# @param [Hash{Symbol => Object}] options
129
+
# See [Mongo::Client options](https://docs.mongodb.org/ecosystem/tutorial/ruby-driver-tutorial-2-0/#uri-options-conversions) for more information on Mongo Client options.
130
+
# @option options [String, #to_s] :title (nil)
131
+
# @option options [String] :host
132
+
# a single address or an array of addresses, which may contain a port designation
133
+
# @option options [Integer] :port (27017) applied to host address(es)
134
+
# @option options [String] :database ('quadb')
135
+
# @option options [String] :collection ('quads')
136
+
#
133
137
# @yield [repository]
134
138
# @yieldparam [Repository] repository
135
139
definitialize(options={}, &block)
140
+
collection=nil
136
141
ifoptions[:uri]
137
142
options=options.dup
138
-
uri=RDF::URI(options[:uri])
139
-
options[:host] ||= uri.host
140
-
options[:port] ||= uri.port
141
-
_,db,collection=uri.path.split('/')
142
-
options[:db] ||= db
143
-
options[:collection] ||= collection
143
+
uri=RDF::URI(options.delete(:uri))
144
+
_,db,coll=uri.path.split('/')
145
+
collection=coll || options.delete(:collection)
146
+
db ||= "quadb"
147
+
uri.path="/#{db}"ifcoll
148
+
@client= ::Mongo::Client.new(uri.to_s,options)
144
149
else
145
150
warn"[DEPRECATION] RDF::Mongo::Repository#initialize expects a uri argument. Called from #{Gem.location_of_caller.join(':')}"unlessoptions.empty?
0 commit comments