flipper-mongo 0.10.1 → 0.10.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/flipper/adapters/mongo.rb +32 -17
- data/lib/flipper/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7891f99a1fdfd655c3bd35799f5ff5538c368762
|
4
|
+
data.tar.gz: df2070a28f90ffd63a7b187a6c6c34c8aa28db38
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 21e873aecd058e8fd1b3bef37c047a8edf056c0fcdfc3001a90ce25b5d6de893f400f812abee528ba5a343dbc189a54fb4436aa0c48fe814f8c7a2631132bc20
|
7
|
+
data.tar.gz: 252121e68251b1e6c1a233b13a980c7aaadcc12f88714b3152e2040aab4a32abc7b6b2e9db7f26d5ebc3650a0447a35a1f0dfba74bcd5722b401eb3de49eff6a
|
@@ -46,20 +46,16 @@ module Flipper
|
|
46
46
|
#
|
47
47
|
# Returns a Hash of Flipper::Gate#key => value.
|
48
48
|
def get(feature)
|
49
|
-
result = {}
|
50
49
|
doc = find(feature.key)
|
50
|
+
result_for_feature(feature, doc)
|
51
|
+
end
|
51
52
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
doc.fetch(gate.key.to_s) { Set.new }.to_set
|
58
|
-
else
|
59
|
-
unsupported_data_type gate.data_type
|
60
|
-
end
|
53
|
+
def get_multi(features)
|
54
|
+
docs = find_many(features.map(&:key))
|
55
|
+
result = {}
|
56
|
+
features.each do |feature|
|
57
|
+
result[feature.key] = result_for_feature(feature, docs[feature.key])
|
61
58
|
end
|
62
|
-
|
63
59
|
result
|
64
60
|
end
|
65
61
|
|
@@ -116,23 +112,42 @@ module Flipper
|
|
116
112
|
|
117
113
|
# Private
|
118
114
|
def find(key)
|
119
|
-
@collection.find(
|
115
|
+
@collection.find({:_id => key.to_s}).limit(1).first || {}
|
116
|
+
end
|
117
|
+
|
118
|
+
def find_many(keys)
|
119
|
+
docs = @collection.find({_id: {'$in' => keys}}).to_a
|
120
|
+
result = Hash.new { |hash, key| hash[key] = {} }
|
121
|
+
docs.each do |doc|
|
122
|
+
result[doc["_id"]] = doc
|
123
|
+
end
|
124
|
+
result
|
120
125
|
end
|
121
126
|
|
122
127
|
# Private
|
123
128
|
def update(key, updates)
|
124
129
|
options = {:upsert => true}
|
125
|
-
@collection.find(
|
130
|
+
@collection.find({:_id => key.to_s}).update_one(updates, options)
|
126
131
|
end
|
127
132
|
|
128
133
|
# Private
|
129
134
|
def delete(key)
|
130
|
-
@collection.find(
|
135
|
+
@collection.find({:_id => key.to_s}).delete_one
|
131
136
|
end
|
132
137
|
|
133
|
-
|
134
|
-
|
135
|
-
|
138
|
+
def result_for_feature(feature, doc)
|
139
|
+
result = {}
|
140
|
+
feature.gates.each do |gate|
|
141
|
+
result[gate.key] = case gate.data_type
|
142
|
+
when :boolean, :integer
|
143
|
+
doc[gate.key.to_s]
|
144
|
+
when :set
|
145
|
+
doc.fetch(gate.key.to_s) { Set.new }.to_set
|
146
|
+
else
|
147
|
+
unsupported_data_type gate.data_type
|
148
|
+
end
|
149
|
+
end
|
150
|
+
result
|
136
151
|
end
|
137
152
|
end
|
138
153
|
end
|
data/lib/flipper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-mongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: flipper
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.10.
|
19
|
+
version: 0.10.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.10.
|
26
|
+
version: 0.10.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: mongo
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|