mingo 0.4.4 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2463c395e95c4c6a4cc6576e965bc0de69275cca
4
- data.tar.gz: fea3e272904915b56f4cfb3accb0ee4cdf6c58fc
3
+ metadata.gz: a579e94fd7e2a8aec302b92521e82fa6c2b549d4
4
+ data.tar.gz: e6c468d34b474a4926df466d7d814f2dea94c638
5
5
  SHA512:
6
- metadata.gz: ea331682889101a6c81969dd1fc59eda16817c9eea9fe08a169b49b0bb4e20b915ae31ea1a18212fc72e9f86bbe110b57db88be7342777ab582b669955c44f66
7
- data.tar.gz: 71b6e51308ccafbc79b0725d6eef065058a52d9d12e27212c46096f74d691062a6c66e0fffd679f4d49e7f29959a0ebc7817a83b26f8cf73798d328f88a822a0
6
+ metadata.gz: 200239ed6548f02b4a5ff21d61c4f32c4799d2c77ae822f90e4cc2f5a283a29f37c7efb15c6117e695fe8da0bd27577da2788fcc0d99afe249241951b3cac5cf
7
+ data.tar.gz: da295d88f2184028838cb97ec6fd14d73d77b8304d2162d67d79590e7c2d55b45982dffd69b19166ef75247f75fe6bad48cb59ea550c2b1972482e1264f653ab
data/Rakefile CHANGED
@@ -1,5 +1,5 @@
1
1
  task :default => :spec
2
2
 
3
3
  task :spec do
4
- exec *%w[bundle exec ruby -Ilib lib/mingo.rb --color]
4
+ exec *%w[bundle exec rspec spec]
5
5
  end
data/lib/mingo/changes.rb CHANGED
@@ -35,11 +35,17 @@ class Mingo
35
35
  end
36
36
 
37
37
  def values_for_update
38
- changes.inject('$set' => {}, '$unset' => {}) do |doc, (key, values)|
38
+ changes.inject({}) do |doc, (key, values)|
39
39
  value = values[1]
40
- value.nil? ? (doc['$unset'][key] = 1) : (doc['$set'][key] = value)
40
+ if value
41
+ doc['$set'] ||= {}
42
+ doc['$set'][key] = value
43
+ else
44
+ doc['$unset'] ||= {}
45
+ doc['$unset'][key] = 1
46
+ end
41
47
  doc
42
48
  end
43
49
  end
44
50
  end
45
- end
51
+ end
@@ -25,7 +25,7 @@ class Mingo
25
25
  def save(options = {})
26
26
  if persisted?
27
27
  hash = values_for_update
28
- unless %w[$set $unset] == hash.keys && hash.values.all? { |v| v.empty? }
28
+ unless hash.empty?
29
29
  update(hash, options)
30
30
  end
31
31
  else
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mingo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mislav Marohnić
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-15 00:00:00.000000000 Z
11
+ date: 2017-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo
@@ -61,9 +61,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
61
61
  version: '0'
62
62
  requirements: []
63
63
  rubyforge_project:
64
- rubygems_version: 2.4.5
64
+ rubygems_version: 2.4.5.1
65
65
  signing_key:
66
66
  specification_version: 4
67
67
  summary: Minimal Mongo
68
68
  test_files: []
69
- has_rdoc: