flipper-sequel 0.16.2 → 0.19.1

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
- SHA1:
3
- metadata.gz: c537e62f6e618caf376cebb4629ae15bca98ab9e
4
- data.tar.gz: adf62476d3e6c2da3fb3af5764ff84a1dd0d52f9
2
+ SHA256:
3
+ metadata.gz: 8cdbdd150893b3aaa0278f778546e6155c0aa57a9569d2a1a1140ae789b60ce8
4
+ data.tar.gz: 89fafbdf7fc4aea5916ed0e507b50cef7e409cf30d41120c0e20e3c6095a2ffb
5
5
  SHA512:
6
- metadata.gz: 6e64828fab17918eee38a9f30ca43cd9df0476b8c1d38f511408649474c031d9b209ce035e6beb26710e32185836579995584690c1e6ddadeef2a3fcf8446165
7
- data.tar.gz: ebb49fc205c96870beae0c67c54e15ff1bac4752962b8bd476337aee2d8178f22c7d9a73e15838b2593f0cfdbd64f1b4a81ce27c9ae87f20a0e8985f40b9189a
6
+ metadata.gz: 1680ec7e20055891c2a084a45455c3b57af2a8ee2eb8bc96c52f6b4df53fa223cfd1318355fc8a0b0fefc1c1a3d2d6a4eb5ed10fd6aba2fca997002949f9b839
7
+ data.tar.gz: 2c0643cde3b55b1da4b73631ac5914f6006835904671202cb9cfdc3f688872085925f19277ce8884d856d55a81c14594a9e13af793d7e78dcabe811ccf17d27a
@@ -8,7 +8,6 @@ Gem::Specification.new do |gem|
8
8
  gem.authors = ['John Nunemaker']
9
9
  gem.email = ['nunemaker@gmail.com']
10
10
  gem.summary = 'Sequel adapter for Flipper'
11
- gem.description = 'Sequel adapter for Flipper'
12
11
  gem.license = 'MIT'
13
12
  gem.homepage = 'https://github.com/jnunemaker/flipper'
14
13
 
@@ -120,15 +120,10 @@ module Flipper
120
120
  # Returns true.
121
121
  def enable(feature, gate, thing)
122
122
  case gate.data_type
123
- when :boolean, :integer
124
- @gate_class.db.transaction do
125
- args = {
126
- feature_key: feature.key,
127
- key: gate.key.to_s,
128
- }
129
- @gate_class.where(args).delete
130
- @gate_class.create(gate_attrs(feature, gate, thing))
131
- end
123
+ when :boolean
124
+ set(feature, gate, thing, clear: true)
125
+ when :integer
126
+ set(feature, gate, thing)
132
127
  when :set
133
128
  begin
134
129
  @gate_class.create(gate_attrs(feature, gate, thing))
@@ -153,15 +148,7 @@ module Flipper
153
148
  when :boolean
154
149
  clear(feature)
155
150
  when :integer
156
- @gate_class.db.transaction do
157
- args = {
158
- feature_key: feature.key.to_s,
159
- key: gate.key.to_s,
160
- }
161
- @gate_class.where(args).delete
162
-
163
- @gate_class.create(gate_attrs(feature, gate, thing))
164
- end
151
+ set(feature, gate, thing)
165
152
  when :set
166
153
  @gate_class.where(gate_attrs(feature, gate, thing))
167
154
  .delete
@@ -178,6 +165,20 @@ module Flipper
178
165
  raise "#{data_type} is not supported by this adapter"
179
166
  end
180
167
 
168
+ def set(feature, gate, thing, options = {})
169
+ clear_feature = options.fetch(:clear, false)
170
+ args = {
171
+ feature_key: feature.key,
172
+ key: gate.key.to_s,
173
+ }
174
+
175
+ @gate_class.db.transaction do
176
+ clear(feature) if clear_feature
177
+ @gate_class.where(args).delete
178
+ @gate_class.create(gate_attrs(feature, gate, thing))
179
+ end
180
+ end
181
+
181
182
  def gate_attrs(feature, gate, thing)
182
183
  {
183
184
  feature_key: feature.key.to_s,
@@ -192,12 +193,12 @@ module Flipper
192
193
  result[gate.key] =
193
194
  case gate.data_type
194
195
  when :boolean
195
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
196
- db_gate.value
196
+ if detected_db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
197
+ detected_db_gate.value
197
198
  end
198
199
  when :integer
199
- if db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
200
- db_gate.value
200
+ if detected_db_gate = db_gates.detect { |db_gate| db_gate.key == gate.key.to_s }
201
+ detected_db_gate.value
201
202
  end
202
203
  when :set
203
204
  db_gates.select { |db_gate| db_gate.key == gate.key.to_s }.map(&:value).to_set
@@ -1,3 +1,3 @@
1
1
  module Flipper
2
- VERSION = '0.16.2'.freeze
2
+ VERSION = '0.19.1'.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.16.2
4
+ version: 0.19.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Nunemaker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-20 00:00:00.000000000 Z
11
+ date: 2020-12-04 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.16.2
19
+ version: 0.19.1
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.16.2
26
+ version: 0.19.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: sequel
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -44,7 +44,7 @@ dependencies:
44
44
  - - "<"
45
45
  - !ruby/object:Gem::Version
46
46
  version: '6'
47
- description: Sequel adapter for Flipper
47
+ description:
48
48
  email:
49
49
  - nunemaker@gmail.com
50
50
  executables: []
@@ -81,8 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  requirements: []
84
- rubyforge_project:
85
- rubygems_version: 2.4.5.4
84
+ rubygems_version: 3.0.3
86
85
  signing_key:
87
86
  specification_version: 4
88
87
  summary: Sequel adapter for Flipper