kongo 1.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/kongo.rb +7 -6
- data/lib/kongo/version.rb +1 -1
- metadata +1 -1
data/lib/kongo.rb
CHANGED
@@ -34,7 +34,7 @@ module Kongo
|
|
34
34
|
# Otherwise finds by value.
|
35
35
|
#
|
36
36
|
def find_by_id(id)
|
37
|
-
id = BSON::ObjectId(id) if BSON::ObjectId.legal?(id)
|
37
|
+
id = BSON::ObjectId(id) if id.is?(String) && BSON::ObjectId.legal?(id)
|
38
38
|
find_one(_id: id)
|
39
39
|
end
|
40
40
|
|
@@ -103,9 +103,10 @@ module Kongo
|
|
103
103
|
def coll
|
104
104
|
return @coll if @coll
|
105
105
|
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
@coll ||= begin
|
107
|
+
raise 'Kongo has not been initialized with a collection fetcher.' unless @@collection_fetcher
|
108
|
+
@@collection_fetcher.call(@coll_name)
|
109
|
+
end
|
109
110
|
end
|
110
111
|
|
111
112
|
|
@@ -307,7 +308,7 @@ module Kongo
|
|
307
308
|
def save!(options = {})
|
308
309
|
warn("#{Kernel.caller.first}: `save` is deprecated, use `update` instead.")
|
309
310
|
raise if @stale unless options[:ignore_stale] # TODO: custom exception
|
310
|
-
@coll.save(@hash, :
|
311
|
+
@coll.save(@hash, :w => 1)
|
311
312
|
end
|
312
313
|
|
313
314
|
# Issues an update on the database, for this record, with the provided
|
@@ -327,7 +328,7 @@ module Kongo
|
|
327
328
|
|
328
329
|
@stale = true
|
329
330
|
|
330
|
-
@coll.update({_id: id}, deltas, :
|
331
|
+
@coll.update({_id: id}, deltas, :w => 1)
|
331
332
|
end
|
332
333
|
|
333
334
|
# Deletes this record from the database.
|
data/lib/kongo/version.rb
CHANGED