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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae15abe1a25ef415ec5f7783b24192ae52cbf86b6d8e8026a7b23d3182db2ea3
4
- data.tar.gz: 92c793efbd0539545f73d363f61df2f3a43d949aafb0bb303ecb5d8a747e660a
3
+ metadata.gz: 6db1458b33ebce656ac2fd6a0aadeb5e2547b5cd346644ec64cf54034f93a461
4
+ data.tar.gz: ab9c8dee420bef036736f998a99411a89c70cdc794cdb96ec0af355a5a682902
5
5
  SHA512:
6
- metadata.gz: a01ae2b84eea1af1a46ed86a0727a38418ec88682fddf0e8829e340f39e368adf7e3451e07b05efc423d874cc6bf70910bfc7afe61267db84c6e8ef90d6f1764
7
- data.tar.gz: 280adedbab88143432826be99f65e17673f9bc0012ddb4c89392b32c6dd2c6ec9ce71a68bf1f79dce2347a631afc5d0f3804092ddbd2d6ef6906fb2af6142534
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
- ActiveSupport.on_load(:active_record) do
12
- # Abstract base class for internal models
13
- class Model < ::ActiveRecord::Base
14
- self.abstract_class = true
15
- end
11
+ class Model < ::ActiveRecord::Base
12
+ self.abstract_class = true
13
+ end
16
14
 
17
- # Private: Do not use outside of this adapter.
18
- class Feature < Model
19
- self.table_name = [
20
- Model.table_name_prefix,
21
- "flipper_features",
22
- Model.table_name_suffix,
23
- ].join
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
- has_many :gates, foreign_key: "feature_key", primary_key: "key"
23
+ has_many :gates, foreign_key: "feature_key", primary_key: "key"
26
24
 
27
- validates :key, presence: true
28
- end
25
+ validates :key, presence: true
26
+ end
29
27
 
30
- # Private: Do not use outside of this adapter.
31
- class Gate < Model
32
- self.table_name = [
33
- Model.table_name_prefix,
34
- "flipper_gates",
35
- Model.table_name_suffix,
36
- ].join
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
- validates :feature_key, presence: true
39
- validates :key, presence: true
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.column_for_attribute(:value).type != :text
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
@@ -1,5 +1,5 @@
1
1
  module Flipper
2
- VERSION = '1.3.4'.freeze
2
+ VERSION = '1.3.5'.freeze
3
3
 
4
4
  REQUIRED_RUBY_VERSION = '2.6'.freeze
5
5
  NEXT_REQUIRED_RUBY_VERSION = '3.0'.freeze
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
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: 2025-03-03 00:00:00.000000000 Z
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.4
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.4
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.4
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.5
92
+ rubygems_version: 3.6.9
93
93
  specification_version: 4
94
94
  summary: ActiveRecord feature flag adapter for Flipper
95
95
  test_files: