this_feature 0.5.1 → 0.5.2

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: b6fdd8f4258c9cca45bdf31d7370e100eb9175102ba565f3368f23a83edf8d46
4
- data.tar.gz: 79c1cbce63fad4511b3a5828fcc90cecb609db1abf2047c01270f7246c1631be
3
+ metadata.gz: 8701f96d9d544b0fa0202e0a0a53df8002ae7d72029758fdb8d19fc23782eb2a
4
+ data.tar.gz: d9a5b268e601e61229c14174773f0de0b251c60b79ef7f13261fd39933d0df82
5
5
  SHA512:
6
- metadata.gz: b8cb49d96981b3320399c856fcd5367e54fc478c9af60e4bfacbf6d2a54a990fa89db7344e8e1b342cbb2a764e57c7b6ca3f7dddec0247fa6f6521250f40f565
7
- data.tar.gz: b3804fb6eb9f37a12e2a8a477ed730ca83ed2cdf7d1a419c39b75ba1d9a4d9243051ee292dfdc59a5d68a2cb3a5d901a2606455916a6a0a22f2b73a5aab27c50
6
+ metadata.gz: 8ee49f04c5e8d234351fc46b8ad248f0ec546b3ae11506071549f985a3032e0def6cb6992c8c442ff6cba2f07fff1fb154b05969f255c3d6f181a8a9244a3d86
7
+ data.tar.gz: 874a68f8416dd2f164f0104a3072ccb4fbb1f81a4f2156f5f8253ecee0c8d5cf7318aa8d1d6c6c1b8fa33a8427f77522c8e2316f1250c78a6e4fa07da5e89836
@@ -4,7 +4,7 @@
4
4
 
5
5
  Under the hood, the memory adapter stores data in a dictionary like so:
6
6
 
7
- ```
7
+ ```json
8
8
  {
9
9
  some_flag_name: {
10
10
  global: false,
@@ -60,6 +60,8 @@ ThisFeature::Adapters::Memory.new(context_key_method: :this_feature_id)
60
60
 
61
61
  If this option is ommitted, then the context object uses its `self` as its "identity".
62
62
 
63
+ **See below for example of how to use on! and off! from tests**
64
+
63
65
  ## API
64
66
 
65
67
  The Memory adapter supports the public API of `ThisFeature`.
@@ -79,7 +81,7 @@ We also support two additional methods here that aren't present on the main adap
79
81
 
80
82
  Usage example of these:
81
83
 
82
- ```
84
+ ```ruby
83
85
  # If you have configured the in-memory adapter as the default
84
86
  ThisFeature.test_adapter.on!(:flag_name, context: user) # with context
85
87
  ThisFeature.test_adapter.off!(:flag_name) # without context
@@ -1 +1,9 @@
1
- todo
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
+
3
+ Make sure your class inherits from `ThisFeature::Adapters::Base` - this is a requirement.
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`.
6
+
7
+ For an example, look at one of the existing adapters: [lib/this_feature/adapters/](../lib/this_feature/adapters/)
8
+
9
+ If you want to include your adapter in our README, just open up a PR.
@@ -19,17 +19,11 @@ class ThisFeature
19
19
  end
20
20
 
21
21
  def on?(flag_name, context: nil, data: {})
22
- return unless present?(flag_name)
23
-
24
22
  client[flag_name].enabled?(*[context].compact)
25
23
  end
26
24
 
27
25
  def off?(flag_name, context: nil, data: {})
28
- on_result = on?(flag_name, context: context)
29
-
30
- return if on_result.nil?
31
-
32
- !on_result
26
+ !on?(flag_name, context: context)
33
27
  end
34
28
 
35
29
  private
@@ -7,6 +7,8 @@ class ThisFeature
7
7
  end
8
8
 
9
9
  def validate_adapters!
10
+ raise(NoAdaptersError.new) unless adapters.any?
11
+
10
12
  adapters.each do |adapter|
11
13
  raise BadAdapterError.new(adapter) unless adapter.class < Adapters::Base
12
14
  end
@@ -14,9 +14,9 @@ class ThisFeature
14
14
  end
15
15
  end
16
16
 
17
- class NoWriteAdapter < Error
17
+ class NoAdaptersError < Error
18
18
  def initialize
19
- super("Use the `ThisFeature.write_adapter=` setter before calling #enable or #disable")
19
+ super("No adapters configured.")
20
20
  end
21
21
  end
22
22
 
@@ -1,3 +1,3 @@
1
1
  class ThisFeature
2
- VERSION = "0.5.1"
2
+ VERSION = "0.5.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: this_feature
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Pleaner
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-10-02 00:00:00.000000000 Z
11
+ date: 2020-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler