flipper-active_record 0.11.0 → 0.12.0

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: 132931f0a03b957491a3899d7624bec349299d0b
4
- data.tar.gz: 369c0e4137231697019e090f5f25caff44eeadf7
3
+ metadata.gz: 7f229cea6ee1375f4e7646c83b5da628e96bb53f
4
+ data.tar.gz: f2e5c18eff0113f078e3b1e8bee95921404d827f
5
5
  SHA512:
6
- metadata.gz: c003998d310119279d893d95f46bd098b95150aee12c41b6fbc92c69fef5e6145008c2fe71afe4eb6000731c68239287ccf8f952ecd52b7582f792ed38c9dc47
7
- data.tar.gz: 25643fd1033438ce1b438d4373fb0c5b13a7bf6593497670bc66bcc5392b70cfb3b467fba5ff0ff1f45a075c8d2181b193a13029f4a7f91c5ee1645dcd7a30df
6
+ metadata.gz: fc26ab0e003c0bf66db5d9733ff7b403edf225a30dd5c1b93577981d471abe5065fe1cf522bcf1eba0a973af3fe1d6c15e9572cc0fd7c56f7349415f5a6df570
7
+ data.tar.gz: 1bfa2802ce615c641bde196294d15a726217f09c0ca59f46c3a5d373faa0d3d243fc4d6c6ac89111aaff79ffaabaea084e27b2338a97af67b30efd3e73006fb4
@@ -113,24 +113,9 @@ module Flipper
113
113
  def enable(feature, gate, thing)
114
114
  case gate.data_type
115
115
  when :boolean, :integer
116
- @gate_class.transaction do
117
- @gate_class.where(
118
- feature_key: feature.key,
119
- key: gate.key
120
- ).delete_all
121
-
122
- @gate_class.create! do |g|
123
- g.feature_key = feature.key
124
- g.key = gate.key
125
- g.value = thing.value.to_s
126
- end
127
- end
116
+ enable_single(feature, gate, thing)
128
117
  when :set
129
- @gate_class.create! do |g|
130
- g.feature_key = feature.key
131
- g.key = gate.key
132
- g.value = thing.value.to_s
133
- end
118
+ enable_multi(feature, gate, thing)
134
119
  else
135
120
  unsupported_data_type gate.data_type
136
121
  end
@@ -178,6 +163,28 @@ module Flipper
178
163
 
179
164
  private
180
165
 
166
+ def enable_single(feature, gate, thing)
167
+ @gate_class.transaction do
168
+ @gate_class.where(feature_key: feature.key, key: gate.key).delete_all
169
+ @gate_class.create! do |g|
170
+ g.feature_key = feature.key
171
+ g.key = gate.key
172
+ g.value = thing.value.to_s
173
+ end
174
+ end
175
+ end
176
+
177
+ def enable_multi(feature, gate, thing)
178
+ @gate_class.create! do |g|
179
+ g.feature_key = feature.key
180
+ g.key = gate.key
181
+ g.value = thing.value.to_s
182
+ end
183
+ rescue ::ActiveRecord::RecordNotUnique
184
+ rescue ::ActiveRecord::StatementInvalid => error
185
+ raise unless error.message =~ /unique/i
186
+ end
187
+
181
188
  def result_for_feature(feature, db_gates)
182
189
  db_gates ||= []
183
190
  result = {}
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.11.0'.freeze
2
+ VERSION = '0.12.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flipper-active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-07 00:00:00.000000000 Z
11
+ date: 2018-01-06 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.11.0
19
+ version: 0.12.0
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.11.0
26
+ version: 0.12.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: activerecord
29
29
  requirement: !ruby/object:Gem::Requirement