flipper-active_record 1.3.4 → 1.3.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/flipper/adapters/active_record.rb +34 -31
- data/lib/flipper/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6db1458b33ebce656ac2fd6a0aadeb5e2547b5cd346644ec64cf54034f93a461
|
4
|
+
data.tar.gz: ab9c8dee420bef036736f998a99411a89c70cdc794cdb96ec0af355a5a682902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4f8a73e94ebfdb0b1547ec276880c3c57e1b79320036af3f75c34bf6e8a1743b3a245351f5eaed5f4f4ed643a9bec6c8cec8954d1e2ac91ae71660b00c5a079d
|
7
|
+
data.tar.gz: a39fbf5b9517806fbaf22e303663ddd33e0a974d7e9913f5793c4ac3ef74cf9aa23782d4dacdad256b672c3a4dcc65b12aabb8520c30490147bf10449039631b
|
@@ -8,40 +8,37 @@ module Flipper
|
|
8
8
|
class ActiveRecord
|
9
9
|
include ::Flipper::Adapter
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
self.abstract_class = true
|
15
|
-
end
|
11
|
+
class Model < ::ActiveRecord::Base
|
12
|
+
self.abstract_class = true
|
13
|
+
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
15
|
+
# Private: Do not use outside of this adapter.
|
16
|
+
class Feature < Model
|
17
|
+
self.table_name = [
|
18
|
+
Model.table_name_prefix,
|
19
|
+
"flipper_features",
|
20
|
+
Model.table_name_suffix,
|
21
|
+
].join
|
24
22
|
|
25
|
-
|
23
|
+
has_many :gates, foreign_key: "feature_key", primary_key: "key"
|
26
24
|
|
27
|
-
|
28
|
-
|
25
|
+
validates :key, presence: true
|
26
|
+
end
|
29
27
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
28
|
+
# Private: Do not use outside of this adapter.
|
29
|
+
class Gate < Model
|
30
|
+
self.table_name = [
|
31
|
+
Model.table_name_prefix,
|
32
|
+
"flipper_gates",
|
33
|
+
Model.table_name_suffix,
|
34
|
+
].join
|
37
35
|
|
38
|
-
|
39
|
-
|
40
|
-
end
|
36
|
+
validates :feature_key, presence: true
|
37
|
+
validates :key, presence: true
|
41
38
|
end
|
42
39
|
|
43
40
|
VALUE_TO_TEXT_WARNING = <<-EOS
|
44
|
-
Your database needs migrated to use the latest Flipper features.
|
41
|
+
Your database needs to be migrated to use the latest Flipper features.
|
45
42
|
Run `rails generate flipper:update` and `rails db:migrate`.
|
46
43
|
EOS
|
47
44
|
|
@@ -59,10 +56,8 @@ module Flipper
|
|
59
56
|
# can roll your own tables and what not, if you so desire.
|
60
57
|
def initialize(options = {})
|
61
58
|
@name = options.fetch(:name, :active_record)
|
62
|
-
@feature_class = options.fetch(:feature_class) { Feature }
|
63
|
-
@gate_class = options.fetch(:gate_class) { Gate }
|
64
|
-
|
65
|
-
warn VALUE_TO_TEXT_WARNING if value_not_text?
|
59
|
+
@feature_class = options.fetch(:feature_class) { Flipper::Adapters::ActiveRecord::Feature }
|
60
|
+
@gate_class = options.fetch(:gate_class) { Flipper::Adapters::ActiveRecord::Gate }
|
66
61
|
end
|
67
62
|
|
68
63
|
# Public: The set of known features.
|
@@ -289,15 +284,23 @@ module Flipper
|
|
289
284
|
# Check if value column is text instead of string
|
290
285
|
# See https://github.com/flippercloud/flipper/pull/692
|
291
286
|
def value_not_text?
|
292
|
-
@gate_class
|
287
|
+
with_connection(@gate_class) do |connection|
|
288
|
+
@gate_class.column_for_attribute(:value).type != :text
|
289
|
+
end
|
293
290
|
rescue ::ActiveRecord::ActiveRecordError => error
|
294
291
|
# If the table doesn't exist, the column doesn't exist either
|
295
292
|
warn "#{error.message}. You likely need to run `rails g flipper:active_record` and/or `rails db:migrate`."
|
296
293
|
end
|
297
294
|
|
298
295
|
def with_connection(model = @feature_class, &block)
|
296
|
+
warn VALUE_TO_TEXT_WARNING if !warned_about_value_not_text? && value_not_text?
|
299
297
|
model.connection_pool.with_connection(&block)
|
300
298
|
end
|
299
|
+
|
300
|
+
def warned_about_value_not_text?
|
301
|
+
return @warned_about_value_not_text if defined?(@warned_about_value_not_text)
|
302
|
+
@warned_about_value_not_text = true
|
303
|
+
end
|
301
304
|
end
|
302
305
|
end
|
303
306
|
end
|
data/lib/flipper/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flipper-active_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- John Nunemaker
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: flipper
|
@@ -15,14 +15,14 @@ dependencies:
|
|
15
15
|
requirements:
|
16
16
|
- - "~>"
|
17
17
|
- !ruby/object:Gem::Version
|
18
|
-
version: 1.3.
|
18
|
+
version: 1.3.5
|
19
19
|
type: :runtime
|
20
20
|
prerelease: false
|
21
21
|
version_requirements: !ruby/object:Gem::Requirement
|
22
22
|
requirements:
|
23
23
|
- - "~>"
|
24
24
|
- !ruby/object:Gem::Version
|
25
|
-
version: 1.3.
|
25
|
+
version: 1.3.5
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: activerecord
|
28
28
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,7 +73,7 @@ metadata:
|
|
73
73
|
homepage_uri: https://www.flippercloud.io
|
74
74
|
source_code_uri: https://github.com/flippercloud/flipper
|
75
75
|
bug_tracker_uri: https://github.com/flippercloud/flipper/issues
|
76
|
-
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.3.
|
76
|
+
changelog_uri: https://github.com/flippercloud/flipper/releases/tag/v1.3.5
|
77
77
|
funding_uri: https://github.com/sponsors/flippercloud
|
78
78
|
rdoc_options: []
|
79
79
|
require_paths:
|
@@ -89,7 +89,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
89
89
|
- !ruby/object:Gem::Version
|
90
90
|
version: '0'
|
91
91
|
requirements: []
|
92
|
-
rubygems_version: 3.6.
|
92
|
+
rubygems_version: 3.6.9
|
93
93
|
specification_version: 4
|
94
94
|
summary: ActiveRecord feature flag adapter for Flipper
|
95
95
|
test_files:
|