featury 1.0.0.rc18 → 1.0.0.rc20
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/README.md +14 -4
- data/lib/featury/actions/action.rb +12 -4
- data/lib/featury/actions/collection.rb +18 -3
- data/lib/featury/info/result.rb +6 -2
- data/lib/featury/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 89e31c544583912d5448fd9fffbed08f5460691a921fdd3a6722dff1c6549ad1
|
4
|
+
data.tar.gz: bcc393cbf53897b0b1168f1d125b22c8d725450a2952817c1e29a3e83c12d787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 554318ae7d5d7b0727e0e9ef262fb020178cf5e1602a87d7800e2ad798691d9581f02f2b1975ccaf9f5d168915dca91a6b10eb2c2d201d51e730aa48d2aadb0a
|
7
|
+
data.tar.gz: 6c1cf235e2cd4d217f0a9c05140c70dd60f4c8d8615e8cce36e7e9be87298d6f970911c79a472085ca65271f48be00815c7cdf02c3ee6ffca8b8075f90a0c54e
|
data/README.md
CHANGED
@@ -40,19 +40,19 @@ In such a scenario, the base class could potentially be structured as follows:
|
|
40
40
|
|
41
41
|
```ruby
|
42
42
|
class ApplicationFeature < Featury::Base
|
43
|
-
action :enabled?, web: :
|
43
|
+
action :enabled?, web: :enabled? do |features:, **options|
|
44
44
|
features.all? { |feature| Flipper.enabled?(feature, *options.values) }
|
45
45
|
end
|
46
46
|
|
47
|
-
action :disabled?, web: :
|
47
|
+
action :disabled?, web: :regular do |features:, **options|
|
48
48
|
features.any? { |feature| !Flipper.enabled?(feature, *options.values) }
|
49
49
|
end
|
50
50
|
|
51
|
-
action :enable, web: :
|
51
|
+
action :enable, web: :enable do |features:, **options|
|
52
52
|
features.all? { |feature| Flipper.enable(feature, *options.values) }
|
53
53
|
end
|
54
54
|
|
55
|
-
action :disable, web: :
|
55
|
+
action :disable, web: :disable do |features:, **options|
|
56
56
|
features.all? { |feature| Flipper.disable(feature, *options.values) }
|
57
57
|
end
|
58
58
|
|
@@ -70,6 +70,16 @@ class ApplicationFeature < Featury::Base
|
|
70
70
|
end
|
71
71
|
```
|
72
72
|
|
73
|
+
#### About the `web:` key
|
74
|
+
|
75
|
+
The `web:` key in the action definition allows you to specify which method will be used for web interactions. This is useful for mapping internal action names to external endpoints or UI actions. For example:
|
76
|
+
|
77
|
+
- `enabled?` — the method that will be used in the web context to check the state of a feature flag;
|
78
|
+
- `enable` — the method that will be used in the web context to enable a feature flag;
|
79
|
+
- `disable` — the method that will be used in the web context to disable a feature flag.
|
80
|
+
|
81
|
+
This mapping helps you clearly separate internal logic from the interface exposed to web clients.
|
82
|
+
|
73
83
|
#### Features of your project
|
74
84
|
|
75
85
|
```ruby
|
@@ -13,12 +13,20 @@ module Featury
|
|
13
13
|
@block = block
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
@web == :
|
16
|
+
def web_enabled?
|
17
|
+
@web == :enabled?
|
18
18
|
end
|
19
19
|
|
20
|
-
def
|
21
|
-
@web == :
|
20
|
+
def web_enable?
|
21
|
+
@web == :enable
|
22
|
+
end
|
23
|
+
|
24
|
+
def web_disable?
|
25
|
+
@web == :disable
|
26
|
+
end
|
27
|
+
|
28
|
+
def web_regular?
|
29
|
+
@web == :regular
|
22
30
|
end
|
23
31
|
end
|
24
32
|
end
|
@@ -11,15 +11,30 @@ module Featury
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def for_web
|
14
|
-
Collection.new(
|
14
|
+
Collection.new(
|
15
|
+
filter do |action|
|
16
|
+
action.web_enabled? ||
|
17
|
+
action.web_enable? ||
|
18
|
+
action.web_disable? ||
|
19
|
+
action.web_regular?
|
20
|
+
end
|
21
|
+
)
|
15
22
|
end
|
16
23
|
|
17
24
|
def names
|
18
25
|
map(&:name)
|
19
26
|
end
|
20
27
|
|
21
|
-
def
|
22
|
-
find(&:
|
28
|
+
def web_enabled
|
29
|
+
find(&:web_enabled?)
|
30
|
+
end
|
31
|
+
|
32
|
+
def web_enable
|
33
|
+
find(&:web_enable?)
|
34
|
+
end
|
35
|
+
|
36
|
+
def web_disable
|
37
|
+
find(&:web_disable?)
|
23
38
|
end
|
24
39
|
|
25
40
|
def find_by(name:)
|
data/lib/featury/info/result.rb
CHANGED
@@ -6,11 +6,15 @@ module Featury
|
|
6
6
|
class Actions
|
7
7
|
class Web
|
8
8
|
attr_reader :all,
|
9
|
-
:
|
9
|
+
:enabled,
|
10
|
+
:enable,
|
11
|
+
:disable
|
10
12
|
|
11
13
|
def initialize(collection_of_actions)
|
12
14
|
@all = collection_of_actions.names
|
13
|
-
@
|
15
|
+
@enabled = collection_of_actions.web_enabled&.name
|
16
|
+
@enable = collection_of_actions.web_enable&.name
|
17
|
+
@disable = collection_of_actions.web_disable&.name
|
14
18
|
end
|
15
19
|
end
|
16
20
|
|
data/lib/featury/version.rb
CHANGED