this_feature 0.7.0 → 0.9.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
  SHA256:
3
- metadata.gz: 8812767db56e7467a7439bc73bd243e3829974f9ee8897b85e434a036d0cdff9
4
- data.tar.gz: b27419213f0bb1954a7d9c221ce315ae2229f2bb27fee13ae92b8987371d7c24
3
+ metadata.gz: 1038dc52ca2faa768e02dd16ac68f71551cad5405932575de6ffbb0be648896d
4
+ data.tar.gz: 9c930c96c3f67226b1a3eef72661320cb77cc275d0ac0fb69f8bd2342eddecf6
5
5
  SHA512:
6
- metadata.gz: cc7fe3136ed720c6eca4aed7ee10a02faf9e3eca3f39302137f7b375e408bf7be7b6259e5fa6ab7b631d9c929fa6c562c25e697cc2ff061a0d204c982dc45a73
7
- data.tar.gz: 6b7e73cead9d55c2c116c9fda04a61c789b2ab8c368d53535958f38f6fe8a7e1191842119e1c469d6d4459a55c4ad722dfdf2e24b9fb64ec95bcbcf5bc1ca36b
6
+ metadata.gz: 96c1151cc8dd148de9c5ba09e62cb1071b6cf18ce168145f07fa27cc4cf0075690deecd3326c6529966c74463bb088112bb8dd5bb5ad61d089a9a528318928af
7
+ data.tar.gz: b9c7ce61ee74dd0dbde08de215e72b8965fb9816a9a88cdfc0d68baa651db933d10801301a9ecb2f5de588d469870f2b479edc04a199f4aee71f94a28a0839d3
@@ -0,0 +1,19 @@
1
+ on: [push]
2
+
3
+ name: Ruby linter (Rubocop)
4
+
5
+ jobs:
6
+ linter_rubocop:
7
+ runs-on: ubuntu-latest
8
+
9
+ steps:
10
+ - name: Checkout
11
+ uses: actions/checkout@main
12
+
13
+ - name: Set up Ruby
14
+ uses: ruby/setup-ruby@v1
15
+ with:
16
+ bundler-cache: true
17
+
18
+ - name: Run Rubocop
19
+ run: bundle exec rubocop --parallel
@@ -1,34 +1,19 @@
1
1
  on: [push]
2
2
 
3
- name: Test
3
+ name: Tests
4
4
 
5
5
  jobs:
6
- run:
6
+ test:
7
7
  runs-on: ubuntu-latest
8
8
 
9
9
  steps:
10
10
  - name: Checkout
11
- uses: actions/checkout@master
11
+ uses: actions/checkout@main
12
12
 
13
13
  - name: Set up Ruby
14
- uses: actions/setup-ruby@v1
14
+ uses: ruby/setup-ruby@master
15
15
  with:
16
- ruby-version: '2.7.x'
17
16
  bundler-cache: true
18
17
 
19
- - name: Cache bundled gems
20
- uses: actions/cache@v2
21
- with:
22
- path: vendor/bundle
23
- key: ${{ runner.os }}-gems-${{ hashFiles('Gemfile.lock') }}
24
- restore-keys: |
25
- ${{ runner.os }}-gems-
26
-
27
- - name: Install Ruby gems
28
- run: |
29
- bundle config path vendor/bundle
30
- bundle install
31
-
32
- - name: Run Rspec
33
- run: |
34
- bundle exec rspec
18
+ - name: Run RSpec
19
+ run: bundle exec rspec
data/.gitignore CHANGED
@@ -1,6 +1,8 @@
1
1
  # sqlite3 database for tests, just called 'memory' for some reason
2
2
  memory
3
3
 
4
+ **/.DS_Store
5
+ *.gem
4
6
  /.bundle/
5
7
  /.yardoc
6
8
  /_yardoc/
data/.rubocop.yml ADDED
@@ -0,0 +1,32 @@
1
+ require:
2
+ - rubocop-md
3
+ - rubocop-performance
4
+ - rubocop-rake
5
+ - rubocop-rspec
6
+ - rubocop-thread_safety
7
+
8
+ inherit_from: .rubocop_todo.yml
9
+
10
+ AllCops:
11
+ NewCops: enable
12
+
13
+ RSpec/NestedGroups:
14
+ Max: 4
15
+
16
+ Style/Documentation:
17
+ Enabled: false
18
+
19
+ Style/FrozenStringLiteralComment:
20
+ EnforcedStyle: never
21
+
22
+ Style/HashSyntax:
23
+ EnforcedStyle: ruby19
24
+ EnforcedShorthandSyntax: never
25
+
26
+ Style/WordArray:
27
+ Exclude:
28
+ - spec/support/schema.rb
29
+
30
+ Style/NumericLiterals:
31
+ Exclude:
32
+ - 'spec/support/schema.rb'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,100 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2023-05-31 05:59:25 UTC using RuboCop version 1.51.0.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
10
+ # Configuration parameters: AllowComments, AllowEmptyLambdas.
11
+ Lint/EmptyBlock:
12
+ Exclude:
13
+ - 'spec/this_feature_spec.rb'
14
+
15
+ # Offense count: 3
16
+ Lint/MissingSuper:
17
+ Exclude:
18
+ - 'lib/this_feature/adapters/flipper.rb'
19
+ - 'lib/this_feature/adapters/memory.rb'
20
+ - 'lib/this_feature/adapters/split_io.rb'
21
+
22
+ # Offense count: 23
23
+ # This cop supports safe autocorrection (--autocorrect).
24
+ # Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
25
+ Lint/UnusedMethodArgument:
26
+ Exclude:
27
+ - '**/*.md'
28
+ - '**/*.markdown'
29
+ - 'lib/this_feature/adapters/base.rb'
30
+ - 'lib/this_feature/adapters/flipper.rb'
31
+ - 'lib/this_feature/adapters/memory.rb'
32
+
33
+ # Offense count: 1
34
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
35
+ Metrics/AbcSize:
36
+ Max: 19
37
+
38
+ # Offense count: 1
39
+ RSpec/AnyInstance:
40
+ Exclude:
41
+ - 'spec/this_feature/adapters/split_io_adapter_spec.rb'
42
+
43
+ # Offense count: 10
44
+ # Configuration parameters: CountAsOne.
45
+ RSpec/ExampleLength:
46
+ Max: 12
47
+
48
+ # Offense count: 4
49
+ # Configuration parameters: Max.
50
+ RSpec/IndexedLet:
51
+ Exclude:
52
+ - 'spec/this_feature/adapters/memory_adapter_spec.rb'
53
+
54
+ # Offense count: 3
55
+ # Configuration parameters: .
56
+ # SupportedStyles: have_received, receive
57
+ RSpec/MessageSpies:
58
+ EnforcedStyle: receive
59
+
60
+ # Offense count: 23
61
+ RSpec/MultipleExpectations:
62
+ Max: 12
63
+
64
+ # Offense count: 72
65
+ # Configuration parameters: AllowSubject.
66
+ RSpec/MultipleMemoizedHelpers:
67
+ Max: 10
68
+
69
+ # Offense count: 9
70
+ # Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
71
+ # SupportedStyles: always, named_only
72
+ RSpec/NamedSubject:
73
+ Exclude:
74
+ - 'spec/this_feature/adapters/flipper_adapter_spec.rb'
75
+ - 'spec/this_feature/adapters/memory_adapter_spec.rb'
76
+ - 'spec/this_feature_spec.rb'
77
+
78
+ # Offense count: 1
79
+ # Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
80
+ RSpec/VerifiedDoubles:
81
+ Exclude:
82
+ - 'spec/this_feature_spec.rb'
83
+
84
+ # Offense count: 3
85
+ Style/MultilineBlockChain:
86
+ Exclude:
87
+ - 'spec/this_feature/adapters/base_adapter_spec.rb'
88
+ - 'spec/this_feature_spec.rb'
89
+
90
+ # Offense count: 15
91
+ Style/OpenStructUse:
92
+ Exclude:
93
+ - 'spec/this_feature/adapters/flipper_adapter_spec.rb'
94
+ - 'spec/this_feature/adapters/memory_adapter_spec.rb'
95
+ - 'spec/this_feature/adapters/split_io_adapter_spec.rb'
96
+
97
+ # Offense count: 2
98
+ ThreadSafety/InstanceVariableInClassMethod:
99
+ Exclude:
100
+ - 'lib/this_feature.rb'
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.2.2
data/Gemfile CHANGED
@@ -1,5 +1,18 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gemspec name: "this_feature"
4
- gemspec name: "this_feature-adapters-flipper"
5
- gemspec name: "this_feature-adapters-split_io"
3
+ gemspec name: 'this_feature'
4
+ gemspec name: 'this_feature-adapters-flipper'
5
+ gemspec name: 'this_feature-adapters-split_io'
6
+
7
+ gem 'bundler'
8
+ gem 'database_cleaner-active_record'
9
+ gem 'gem-release'
10
+ gem 'rake'
11
+ gem 'rspec'
12
+ gem 'rubocop'
13
+ gem 'rubocop-md'
14
+ gem 'rubocop-performance'
15
+ gem 'rubocop-rake'
16
+ gem 'rubocop-rspec'
17
+ gem 'rubocop-thread_safety'
18
+ gem 'sqlite3'
data/Gemfile.lock CHANGED
@@ -1,39 +1,37 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- this_feature (0.7.0)
5
- this_feature-adapters-flipper (0.7.0)
6
- flipper (~> 0.16)
7
- flipper-active_record (~> 0.16)
4
+ this_feature (0.9.0)
5
+ this_feature-adapters-flipper (0.9.0)
6
+ flipper
7
+ flipper-active_record
8
8
  this_feature
9
- this_feature-adapters-split_io (0.7.0)
9
+ this_feature-adapters-split_io (0.9.0)
10
10
  splitclient-rb
11
11
  this_feature
12
12
 
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activemodel (6.1.3)
17
- activesupport (= 6.1.3)
18
- activerecord (6.1.3)
19
- activemodel (= 6.1.3)
20
- activesupport (= 6.1.3)
21
- activesupport (6.1.3)
16
+ activemodel (7.0.5)
17
+ activesupport (= 7.0.5)
18
+ activerecord (7.0.5)
19
+ activemodel (= 7.0.5)
20
+ activesupport (= 7.0.5)
21
+ activesupport (7.0.5)
22
22
  concurrent-ruby (~> 1.0, >= 1.0.2)
23
23
  i18n (>= 1.6, < 2)
24
24
  minitest (>= 5.1)
25
25
  tzinfo (~> 2.0)
26
- zeitwerk (~> 2.3)
27
- byebug (11.1.2)
28
- coderay (1.1.2)
29
- concurrent-ruby (1.1.8)
26
+ ast (2.4.2)
27
+ concurrent-ruby (1.2.2)
30
28
  connection_pool (2.2.5)
31
29
  database_cleaner (1.8.4)
32
30
  database_cleaner-active_record (1.8.0)
33
31
  activerecord
34
32
  database_cleaner (~> 1.8.0)
35
- diff-lcs (1.3)
36
- faraday (1.5.0)
33
+ diff-lcs (1.5.0)
34
+ faraday (1.7.0)
37
35
  faraday-em_http (~> 1.0)
38
36
  faraday-em_synchrony (~> 1.0)
39
37
  faraday-excon (~> 1.1)
@@ -41,6 +39,7 @@ GEM
41
39
  faraday-net_http (~> 1.0)
42
40
  faraday-net_http_persistent (~> 1.1)
43
41
  faraday-patron (~> 1.0)
42
+ faraday-rack (~> 1.0)
44
43
  multipart-post (>= 1.2, < 3)
45
44
  ruby2_keywords (>= 0.0.4)
46
45
  faraday-em_http (1.0.0)
@@ -48,49 +47,80 @@ GEM
48
47
  faraday-excon (1.1.0)
49
48
  faraday-httpclient (1.0.1)
50
49
  faraday-net_http (1.0.1)
51
- faraday-net_http_persistent (1.1.0)
50
+ faraday-net_http_persistent (1.2.0)
52
51
  faraday-patron (1.0.0)
53
- flipper (0.22.0)
54
- flipper-active_record (0.22.0)
55
- activerecord (>= 4.2, < 7)
56
- flipper (~> 0.22.0)
52
+ faraday-rack (1.0.0)
53
+ flipper (0.28.0)
54
+ concurrent-ruby (< 2)
55
+ flipper-active_record (0.28.0)
56
+ activerecord (>= 4.2, < 8)
57
+ flipper (~> 0.28.0)
57
58
  gem-release (2.2.1)
58
59
  hitimes (1.3.1)
59
- i18n (1.8.9)
60
+ i18n (1.13.0)
60
61
  concurrent-ruby (~> 1.0)
61
62
  json (2.5.1)
62
63
  jwt (2.2.3)
63
64
  lru_redux (1.1.0)
64
- method_source (1.0.0)
65
- minitest (5.14.4)
65
+ minitest (5.18.0)
66
66
  multipart-post (2.1.1)
67
67
  net-http-persistent (4.0.1)
68
68
  connection_pool (~> 2.2)
69
- pry (0.13.1)
70
- coderay (~> 1.1)
71
- method_source (~> 1.0)
72
- pry-byebug (3.9.0)
73
- byebug (~> 11.0)
74
- pry (~> 0.13.0)
75
- rake (13.0.1)
76
- redis (4.3.1)
77
- rspec (3.9.0)
78
- rspec-core (~> 3.9.0)
79
- rspec-expectations (~> 3.9.0)
80
- rspec-mocks (~> 3.9.0)
81
- rspec-core (3.9.1)
82
- rspec-support (~> 3.9.1)
83
- rspec-expectations (3.9.1)
69
+ parallel (1.23.0)
70
+ parser (3.2.2.1)
71
+ ast (~> 2.4.1)
72
+ rainbow (3.1.1)
73
+ rake (13.0.6)
74
+ redis (4.4.0)
75
+ regexp_parser (2.8.0)
76
+ rexml (3.2.5)
77
+ rspec (3.12.0)
78
+ rspec-core (~> 3.12.0)
79
+ rspec-expectations (~> 3.12.0)
80
+ rspec-mocks (~> 3.12.0)
81
+ rspec-core (3.12.2)
82
+ rspec-support (~> 3.12.0)
83
+ rspec-expectations (3.12.3)
84
84
  diff-lcs (>= 1.2.0, < 2.0)
85
- rspec-support (~> 3.9.0)
86
- rspec-mocks (3.9.1)
85
+ rspec-support (~> 3.12.0)
86
+ rspec-mocks (3.12.5)
87
87
  diff-lcs (>= 1.2.0, < 2.0)
88
- rspec-support (~> 3.9.0)
89
- rspec-support (3.9.2)
90
- ruby2_keywords (0.0.4)
88
+ rspec-support (~> 3.12.0)
89
+ rspec-support (3.12.0)
90
+ rubocop (1.51.0)
91
+ json (~> 2.3)
92
+ parallel (~> 1.10)
93
+ parser (>= 3.2.0.0)
94
+ rainbow (>= 2.2.2, < 4.0)
95
+ regexp_parser (>= 1.8, < 3.0)
96
+ rexml (>= 3.2.5, < 4.0)
97
+ rubocop-ast (>= 1.28.0, < 2.0)
98
+ ruby-progressbar (~> 1.7)
99
+ unicode-display_width (>= 2.4.0, < 3.0)
100
+ rubocop-ast (1.28.1)
101
+ parser (>= 3.2.1.0)
102
+ rubocop-capybara (2.18.0)
103
+ rubocop (~> 1.41)
104
+ rubocop-factory_bot (2.23.1)
105
+ rubocop (~> 1.33)
106
+ rubocop-md (1.2.0)
107
+ rubocop (>= 1.0)
108
+ rubocop-performance (1.18.0)
109
+ rubocop (>= 1.7.0, < 2.0)
110
+ rubocop-ast (>= 0.4.0)
111
+ rubocop-rake (0.6.0)
112
+ rubocop (~> 1.0)
113
+ rubocop-rspec (2.22.0)
114
+ rubocop (~> 1.33)
115
+ rubocop-capybara (~> 2.17)
116
+ rubocop-factory_bot (~> 2.22)
117
+ rubocop-thread_safety (0.5.1)
118
+ rubocop (>= 0.90.0)
119
+ ruby-progressbar (1.13.0)
120
+ ruby2_keywords (0.0.5)
91
121
  socketry (0.5.1)
92
122
  hitimes (~> 1.2)
93
- splitclient-rb (7.2.3)
123
+ splitclient-rb (7.3.1)
94
124
  concurrent-ruby (~> 1.0)
95
125
  faraday (>= 0.8)
96
126
  json (>= 1.8)
@@ -102,24 +132,29 @@ GEM
102
132
  thread_safe (>= 0.3)
103
133
  sqlite3 (1.4.2)
104
134
  thread_safe (0.3.6)
105
- tzinfo (2.0.4)
135
+ tzinfo (2.0.6)
106
136
  concurrent-ruby (~> 1.0)
107
- zeitwerk (2.4.2)
137
+ unicode-display_width (2.4.2)
108
138
 
109
139
  PLATFORMS
110
140
  ruby
111
141
 
112
142
  DEPENDENCIES
113
- bundler (~> 2.0)
143
+ bundler
114
144
  database_cleaner-active_record
115
145
  gem-release
116
- pry-byebug
117
- rake (~> 13.0)
118
- rspec (~> 3.0)
146
+ rake
147
+ rspec
148
+ rubocop
149
+ rubocop-md
150
+ rubocop-performance
151
+ rubocop-rake
152
+ rubocop-rspec
153
+ rubocop-thread_safety
119
154
  sqlite3
120
155
  this_feature!
121
156
  this_feature-adapters-flipper!
122
157
  this_feature-adapters-split_io!
123
158
 
124
159
  BUNDLED WITH
125
- 2.1.4
160
+ 2.4.13
data/README.md CHANGED
@@ -4,9 +4,7 @@
4
4
 
5
5
  ThisFeature can be used to more easily migrate from one feature flag service to another
6
6
 
7
- If your code uses ThisFeature,
8
- then you can just swap out the vendor adapter without needing to do a bunch of find-and-replace in your codebase
9
- from one vendor's class/method signature to the another's.
7
+ If your code uses ThisFeature, then you can just swap out the vendor adapter without needing to do a bunch of find-and-replace in your codebase from one vendor's class/method signature to the another's.
10
8
 
11
9
  ## Installation
12
10
 
@@ -68,7 +66,7 @@ ThisFeature.flag('flag_name', context: context, data: { org_id: 1 }).on?
68
66
 
69
67
  ### Avoid Pitfalls
70
68
 
71
- 1. If your flag has context-specific rules (e.g. on for some orgs, off for others), make sure that the code does a context-specific check. `ThisFeature.flag("flag_name").on?` may return true, while `ThisFeature.flag("flag_name", context: Org.first).on?` would return false.
69
+ 1. If your flag has context-specific rules (e.g. on for some orgs, off for others), make sure that the code does a context-specific check. `ThisFeature.flag("flag_name").on?` may return true, while `ThisFeature.flag("flag_name", context: Org.first).on?` would return false.
72
70
  2. Related to the previous bullet point, if you are checking whether a flag is "globally enabled" (and thus may be removed from the codebase), do not just use `ThisFeature.flag("flag_name").on?`, it won't tell you the whole story. Go to the vendor console and check whether there are context-specific rules enabled.
73
71
 
74
72
  ## Available Adapters
@@ -103,6 +101,3 @@ To write a new adapter, check the [Guide](./docs/writing_an_adapter.md).
103
101
  ## License
104
102
 
105
103
  ThisFeature is released under the [MIT License](https://choosealicense.com/licenses/mit).
106
-
107
-
108
-
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
3
 
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
- task :default => :spec
6
+ task default: :spec
data/bin/console CHANGED
@@ -1,14 +1,10 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require "bundler/setup"
4
- require "this_feature"
3
+ require 'bundler/setup'
4
+ require 'this_feature'
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
8
8
 
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
9
+ require 'irb'
14
10
  IRB.start(__FILE__)
data/docs/flipper.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Installation
4
4
 
5
5
  ```ruby
6
- gem 'this_feature-adapters-flipper
6
+ gem 'this_feature-adapters-flipper'
7
7
  ```
8
8
 
9
9
  ## Configuration
data/docs/memory.md CHANGED
@@ -24,7 +24,7 @@ in test suites.
24
24
  This adapter is included with the core gem:
25
25
 
26
26
  ```ruby
27
- gem 'this_feature
27
+ gem 'this_feature'
28
28
  ```
29
29
 
30
30
  ## Configuration
@@ -50,7 +50,7 @@ For example:
50
50
  # of a context object (e.g. imagine this module is included onto User)
51
51
  module FeatureFlaggable
52
52
  def this_feature_id
53
- "#{self.class}-#{self.id}"
53
+ "#{self.class}-#{id}"
54
54
  end
55
55
  end
56
56
 
data/docs/splitio.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Installation
4
4
 
5
5
  ```ruby
6
- gem 'this_feature-adapters-split-io
6
+ gem 'this_feature-adapters-split-io'
7
7
  ```
8
8
 
9
9
  ## Configuration
@@ -32,4 +32,31 @@ The SplitIo adapter supports the public API of `ThisFeature`.
32
32
 
33
33
  Both `context` and `data` are supported.
34
34
 
35
- `control` is a native Split feature, so we perform a query to Split to get this info.
35
+ `control` is a native Split feature, so we perform a query to Split to get this info.
36
+
37
+ We've also added `record`, which is a helper to easily and consistently add
38
+ attributes to the `data` hash. To take advantage of this, the application must
39
+ set a `base_data_lambda` in the config. An example—
40
+ ```ruby
41
+ ThisFeature.configure do |config|
42
+ config.base_data_lambda = lambda { |record|
43
+ case record
44
+ when Org
45
+ {
46
+ org_id: record.id,
47
+ org_name: record.name
48
+ }
49
+ when User
50
+ {
51
+ org_id: record.org.id,
52
+ org_name: record.org.name,
53
+ user_email: record.email,
54
+ user_id: record.id,
55
+ user_name: record.name
56
+ }
57
+ end
58
+ }
59
+ end
60
+ ```
61
+ Then `ThisFeature.flag("my-flag", record: user).on?` will automatically include
62
+ org_id, org_name, user_email, user_id, and user_name in the data attributes.
@@ -1,8 +1,8 @@
1
- Look at [lib/this_feature/adapters/base.rb](../lib/this_feature/adapters/base.rb) to see the methods that your class should implement.
1
+ Look at [lib/this_feature/adapters/base.rb](../lib/this_feature/adapters/base.rb) to see the methods that your class should implement.
2
2
 
3
- Make sure your class inherits from `ThisFeature::Adapters::Base` - this is a requirement.
3
+ Make sure your class inherits from `ThisFeature::Adapters::Base` - this is a requirement.
4
4
 
5
- You may define a custom `initialize` method - this isn't used by `this_feature` internals because we require an already-constructed instance to be passed into `ThisFeature.configure`.
5
+ You may define a custom `initialize` method - this isn't used by `this_feature` internals because we require an already-constructed instance to be passed into `ThisFeature.configure`.
6
6
 
7
7
  For an example, look at one of the existing adapters: [lib/this_feature/adapters/](../lib/this_feature/adapters/)
8
8
 
@@ -5,11 +5,11 @@ class ThisFeature
5
5
  raise UnimplementedError.new(self, __method__)
6
6
  end
7
7
 
8
- def on?(flag_name, context: nil, data: {})
8
+ def on?(flag_name, context: nil, data: {}, record: nil)
9
9
  raise UnimplementedError.new(self, __method__)
10
10
  end
11
11
 
12
- def off?(flag_name, context: nil, data: {})
12
+ def off?(flag_name, context: nil, data: {}, record: nil)
13
13
  raise UnimplementedError.new(self, __method__)
14
14
  end
15
15
 
@@ -1,5 +1,5 @@
1
- require "flipper"
2
- require "flipper/adapters/active_record"
1
+ require 'flipper'
2
+ require 'flipper/adapters/active_record'
3
3
 
4
4
  class ThisFeature
5
5
  module Adapters
@@ -18,11 +18,11 @@ class ThisFeature
18
18
  !present?(flag_name)
19
19
  end
20
20
 
21
- def on?(flag_name, context: nil, data: {})
21
+ def on?(flag_name, context: nil, data: {}, record: nil)
22
22
  client[flag_name].enabled?(*[context].compact)
23
23
  end
24
24
 
25
- def off?(flag_name, context: nil, data: {})
25
+ def off?(flag_name, context: nil, data: {}, record: nil)
26
26
  !on?(flag_name, context: context)
27
27
  end
28
28
 
@@ -1,7 +1,6 @@
1
1
  class ThisFeature
2
2
  module Adapters
3
3
  class Memory < Base
4
-
5
4
  def initialize(context_key_method: nil)
6
5
  @context_key_method = context_key_method
7
6
  end
@@ -14,7 +13,7 @@ class ThisFeature
14
13
  !storage[flag_name].nil?
15
14
  end
16
15
 
17
- def on?(flag_name, context: nil, data: {})
16
+ def on?(flag_name, context: nil, data: {}, record: nil)
18
17
  return false unless present?(flag_name)
19
18
 
20
19
  flag_data = storage[flag_name]
@@ -27,7 +26,7 @@ class ThisFeature
27
26
  !!flag_data[:contexts][context_key(context)]
28
27
  end
29
28
 
30
- def off?(flag_name, context: nil, data: {})
29
+ def off?(flag_name, context: nil, data: {}, record: nil)
31
30
  !on?(flag_name, context: context, data: data)
32
31
  end
33
32