flipper-sequel 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59cf196b2a751050922c4c9c8f1a6a08315eb876
4
- data.tar.gz: 6a768a34c2f498d9819578931b1117a43443074a
3
+ metadata.gz: 90e3061ed905c5f60e924d150ab6528c9c0441cb
4
+ data.tar.gz: 427a99d66693ebd319e32b152167c7d6a1c5ca86
5
5
  SHA512:
6
- metadata.gz: 2944cca500081cc6cc4d6738106bcaac9d169b22e04d0364e1dce420b90bd347eb43e563102c1e763479ae2f2bb75cfa1c1a496fd3cdd7b7e97176b36f125785
7
- data.tar.gz: f7dc2698a11640af38fee19b567c0e859c3c4eb8e5f953f202e9ccd13a4b34211d5f79afafc3eed8b4d2c18f4adcfdac84283da0c99d7156fe896d2eeb29f170
6
+ metadata.gz: a6427b163839819f4eb5bf9776553ddada04aab33b316f67b96d1ce4eea53b7c597ef622fa442588e491d545e41cd5751b34617a20981c3e36a8f47eeb3d2b35
7
+ data.tar.gz: 60da3d47612c6d2b559cb22c593bbcd8843c46ecebb2887110497c572378bf3df9b1976e5233701bb439fea627dae5b3a52ae9f4ac6a77e73fb680549f471659
@@ -72,22 +72,17 @@ module Flipper
72
72
  def get(feature)
73
73
  db_gates = @gate_class.where(feature_key: feature.key.to_s).all
74
74
 
75
- feature.gates.each_with_object({}) do |gate, result|
76
- result[gate.key] = case gate.data_type
77
- when :boolean
78
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
79
- db_gate.value
80
- end
81
- when :integer
82
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
83
- db_gate.value
84
- end
85
- when :set
86
- db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
87
- else
88
- unsupported_data_type gate.data_type
89
- end
75
+ result_for_feature(feature, db_gates)
76
+ end
77
+
78
+ def get_multi(features)
79
+ db_gates = @gate_class.where(feature_key: features.map(&:key)).to_a
80
+ grouped_db_gates = db_gates.group_by { |gate| gate.feature_key }
81
+ result = {}
82
+ features.each do |feature|
83
+ result[feature.key] = result_for_feature(feature, grouped_db_gates[feature.key])
90
84
  end
85
+ result
91
86
  end
92
87
 
93
88
  # Public: Enables a gate for a given thing.
@@ -162,6 +157,26 @@ module Flipper
162
157
  value: thing.value.to_s
163
158
  }
164
159
  end
160
+
161
+ def result_for_feature(feature, db_gates)
162
+ db_gates ||= []
163
+ feature.gates.each_with_object({}) do |gate, result|
164
+ result[gate.key] = case gate.data_type
165
+ when :boolean
166
+ if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
167
+ db_gate.value
168
+ end
169
+ when :integer
170
+ if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
171
+ db_gate.value
172
+ end
173
+ when :set
174
+ db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
175
+ else
176
+ unsupported_data_type gate.data_type
177
+ end
178
+ end
179
+ end
165
180
  end
166
181
  end
167
182
  end
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = "0.10.1".freeze
2
+ VERSION = "0.10.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-sequel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.1
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-19 00:00:00.000000000 Z
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.1
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.1
26
+ version: 0.10.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement