kongo 1.2 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/kongo.rb +7 -6
  2. data/lib/kongo/version.rb +1 -1
  3. metadata +1 -1
@@ -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
- raise 'Kongo has not been initialized with a collection fetcher.' unless @@collection_fetcher
107
- @coll = @@collection_fetcher.call(@coll_name)
108
- @coll
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, :safe => true)
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, :safe => true)
331
+ @coll.update({_id: id}, deltas, :w => 1)
331
332
  end
332
333
 
333
334
  # Deletes this record from the database.
@@ -1,3 +1,3 @@
1
1
  module Kongo
2
- VERSION = '1.2'
2
+ VERSION = '1.2.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kongo
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.2'
4
+ version: 1.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: