easymongo 0.0.8 → 0.0.9

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: a232968fb131e4006be5cc53f3cbebc32c58d561
4
- data.tar.gz: d4ee629668945c8fe1a745b0d2dcad9e45d3e19f
3
+ metadata.gz: 3cc4edad2a676e0964494e8c729f585acf7d930f
4
+ data.tar.gz: 2fd7275fd201b7e9d55e70742b273d582403dbf1
5
5
  SHA512:
6
- metadata.gz: 9e9cfaa5eb44d58efd6f7793eba740a7bb570c9a077ef7482ea530511e5e2bbfefeedf99779df47bbd94399b1983a09cd0526e7102be448865c01d729a2f1bba
7
- data.tar.gz: dbdfef2a7546843c9c2fd78f0bc827ff725adbd6243a29646c4d58a2eea03128eb4fbfba2671eadd1a0814a9497e820e4722bbaca8db9760370125d9281bbbf0
6
+ metadata.gz: 371cf2d329cb4e08e209ed381fefe03a3d1afe81ad63480fa24dfbc9e029ae62d37a55e9c643274a9a9644632e65d4818e24ac04bd3629c103a300c20f3113ca
7
+ data.tar.gz: 05fbd236f15b4cc1255e5fda076e0d394c5a44fef231ca65b003e549b25e518216d6e9f62b2d874204d2787608bae5b68a7ab6bf7a800f077e19cfd6ba3e3824
@@ -1,6 +1,6 @@
1
- **Version 0.0.8** - *2017-07-25*
1
+ **Version 0.0.9** - *2017-07-26*
2
2
 
3
- - Added defaults
3
+ - Normalizing values on set
4
4
 
5
5
 
6
6
  **Version 0.0.6** - *2017-07-20*
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'easymongo'
3
- s.version = '0.0.8'
4
- s.date = '2017-07-25'
3
+ s.version = '0.0.9'
4
+ s.date = '2017-07-26'
5
5
  s.summary = "Super Easy MongoDB client"
6
6
  s.description = "The way MongoDB for Ruby should be, can't get easier than this"
7
7
  s.authors = ["Fugroup Limited"]
@@ -31,14 +31,14 @@ module Easymongo
31
31
  # Insert, add oid
32
32
  data, values = args.size == 1 ? [{'_id' => oid}, *args] : args
33
33
 
34
+ # Normalize attributes
35
+ data, values = ids(data), ids(values)
36
+
34
37
  # Using set and unset so we don't store nil in the db
35
38
  options = {
36
39
  :$set => values.select{|k, v| !v.nil?}, :$unset => values.select{|k, v| v.nil?}
37
40
  }.delete_if{|k, v| v.empty?}
38
41
 
39
- # Normalize data
40
- data = ids(data)
41
-
42
42
  # Update the collection
43
43
  result = client[coll].update_one(data, options, :upsert => true)
44
44
 
@@ -113,9 +113,6 @@ module Easymongo
113
113
  # Support passing id as string
114
114
  data = {'_id' => data} if !data or data.is_a?(String)
115
115
 
116
- # Merge in defaults
117
- data = defaults.merge(data)
118
-
119
116
  # Turn all keys to string
120
117
  data = data.stringify_keys
121
118
 
@@ -123,7 +120,11 @@ module Easymongo
123
120
  data['_id'] = data.delete('id') if data['id']
124
121
 
125
122
  # Convert ids to BSON ObjectId
126
- data.each{|k, v| data[k] = oid(v) if v.is_a?(String) and v =~ /^[0-9a-fA-F]{24}$/}
123
+ data.each do |k, v|
124
+ if v.is_a?(String) and v =~ /^[0-9a-fA-F]{24}$/
125
+ data[k] = oid(v)
126
+ end
127
+ end
127
128
 
128
129
  # Return data
129
130
  data
@@ -134,16 +135,6 @@ module Easymongo
134
135
  return BSON::ObjectId.new if v.nil?; BSON::ObjectId.from_string(v) rescue v
135
136
  end
136
137
 
137
- # Set temporary defaults. Useful for logged in users.
138
- def defaults=(val)
139
- s[:defaults] = val
140
- end
141
-
142
- # Get defaults
143
- def defaults
144
- s[:defaults] || {}
145
- end
146
-
147
138
  private
148
139
 
149
140
  # Get the request store
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: easymongo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fugroup Limited
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongo