featury 1.0.0.rc2 → 1.0.0.rc4

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: 8098675501d6667179f6362ab15e8b28667fec0cd365380e6f96940f60167a16
4
- data.tar.gz: b462b0692a217a23db8729d3205012668d5955efe58cff0f586e460aa3f9133d
3
+ metadata.gz: 61aef35ff4aede3e7c747a1b28be3d9ce598b068bc2d355093ac7a6ebb5b0829
4
+ data.tar.gz: 40a570d5c32557cc9d7ab325633df8783676bfe48c58f1985bc943f1bb8c1d48
5
5
  SHA512:
6
- metadata.gz: 9a7e141130c232159477292ed179e8267fc50163f56b4c0d2cfe5b18238b2a7a498bbfd903d659bce143c447cb578c1ffa11e763a07988ecb3a6112286c17b71
7
- data.tar.gz: 24ebf4c4d1802856b78683917c5a717c4180823214e3dfbcbecefe30a53ae38f2558f46f09d7f18b395ebdd492091c6c8cc1fa2e3a61031c30e19d3bf2b0ba23
6
+ metadata.gz: '097cbc783cb17e6648a514190be9bf075868113e089fb21725f9889b92e4293ebe5ea5c2ca49fdebc2ca06c318f37556ca69c56c4703c04a5693de6fbb1eb0de'
7
+ data.tar.gz: 3c41249a7db0ead35e581e6f6e517157b46cec9ee03e4f005f0c6529bb0067ec7c14ed7b130d550ffb22e66a72589638cb259b359137aee3f393db9763896238
data/README.md CHANGED
@@ -30,20 +30,20 @@ In this case, the base class might look like this:
30
30
 
31
31
  ```ruby
32
32
  class ApplicationFeature < Featury::Base
33
- action :enabled? do |features:|
34
- features.all? { |feature| Flipper.enabled?(feature) }
33
+ action :enabled? do |features:, **options|
34
+ features.all? { |feature| Flipper.enabled?(feature, *options.values) }
35
35
  end
36
36
 
37
- action :disabled? do |features:|
38
- features.any? { |feature| !Flipper.enabled?(feature) }
37
+ action :disabled? do |features:, **options|
38
+ features.any? { |feature| !Flipper.enabled?(feature, *options.values) }
39
39
  end
40
40
 
41
- action :enable do |features:|
42
- features.all? { |feature| Flipper.enable(feature) }
41
+ action :enable do |features:, **options|
42
+ features.all? { |feature| Flipper.enable(feature, *options.values) }
43
43
  end
44
44
 
45
- action :disable do |features:|
46
- features.all? { |feature| Flipper.disable(feature) }
45
+ action :disable do |features:, **options|
46
+ features.all? { |feature| Flipper.disable(feature, *options.values) }
47
47
  end
48
48
  end
49
49
  ```
@@ -71,9 +71,6 @@ end
71
71
 
72
72
  ```ruby
73
73
  class BillingFeature < ApplicationFeature
74
- # The user resource is currently needed due to availability and passing from the parent class.
75
- resource :user, type: User
76
-
77
74
  prefix :billing
78
75
 
79
76
  features(
@@ -84,9 +81,6 @@ end
84
81
 
85
82
  ```ruby
86
83
  class PaymentSystemFeature < ApplicationFeature
87
- # The user resource is currently needed due to availability and passing from the parent class.
88
- resource :user, type: User
89
-
90
84
  prefix :payment_system
91
85
 
92
86
  features(
@@ -95,6 +89,21 @@ class PaymentSystemFeature < ApplicationFeature
95
89
  end
96
90
  ```
97
91
 
92
+ The `resource` method can indicate how the transmitted information should be processed.
93
+ In addition to the options that Servactory brings, there are options for specifying the processing mode of the transmitted data.
94
+
95
+ If it is necessary for a resource to be transferred as an option for a feature flag, then use the `option` option:
96
+
97
+ ```ruby
98
+ resource :user, type: User, option: true
99
+ ```
100
+
101
+ If it is necessary for a resource to be transferred to a nested group, then use the `nested` option:
102
+
103
+ ```ruby
104
+ resource :user, type: User, nested: true
105
+ ```
106
+
98
107
  #### Working with the features of your project
99
108
 
100
109
  Each of these actions will be applied to all feature flags.
@@ -5,7 +5,7 @@ module Featury
5
5
  class Action
6
6
  attr_reader :name, :block
7
7
 
8
- def initialize(name, block)
8
+ def initialize(name, block:)
9
9
  @name = name
10
10
  @block = block
11
11
  end
@@ -18,7 +18,10 @@ module Featury
18
18
  private
19
19
 
20
20
  def action(name)
21
- collection_of_actions << Action.new(name, ->(features:) { yield(features: features) })
21
+ collection_of_actions << Action.new(
22
+ name,
23
+ block: ->(features:, **options) { yield(features: features, **options) }
24
+ )
22
25
  end
23
26
 
24
27
  def collection_of_actions
@@ -34,6 +34,7 @@ module Featury
34
34
  builder_class.call!(
35
35
  action: @action,
36
36
  **@incoming_arguments,
37
+ collection_of_resources: @collection_of_resources,
37
38
  collection_of_conditions: @collection_of_conditions,
38
39
  collection_of_features: @collection_of_features,
39
40
  collection_of_groups: @collection_of_groups
@@ -31,6 +31,7 @@ module Featury
31
31
 
32
32
  input :action, type: Featury::Actions::Action
33
33
 
34
+ input :collection_of_resources, type: Featury::Resources::Collection
34
35
  input :collection_of_conditions, type: Featury::Conditions::Collection
35
36
  input :collection_of_features, type: Featury::Features::Collection
36
37
  input :collection_of_groups, type: Featury::Groups::Collection
@@ -56,12 +57,17 @@ module Featury
56
57
  end
57
58
 
58
59
  def check_features
59
- internals.features_are_true = inputs.action.block.call(features: inputs.collection_of_features.list)
60
+ options = inputs.collection_of_resources.only_option.to_h do |resource|
61
+ [resource.name, inputs.public_send(resource.name)]
62
+ end
63
+
64
+ internals.features_are_true =
65
+ inputs.action.block.call(features: inputs.collection_of_features.list, **options)
60
66
  end
61
67
 
62
68
  def check_groups
63
- arguments = inputs.instance_variable_get(:@collection_of_inputs).names.to_h do |input_name|
64
- [input_name, inputs.public_send(input_name)]
69
+ arguments = inputs.collection_of_resources.only_nested.to_h do |resource|
70
+ [resource.name, inputs.public_send(resource.name)]
65
71
  end
66
72
 
67
73
  internals.groups_are_true = inputs.collection_of_groups.all? do |group|
@@ -9,28 +9,6 @@ module Featury
9
9
  def initialize(collection = Set.new)
10
10
  @collection = collection
11
11
  end
12
-
13
- def names
14
- map(&:name)
15
- end
16
-
17
- def internal_names
18
- map { |attribute| attribute.to.name }
19
- end
20
-
21
- def include_class_exist?
22
- @include_class_exist ||= filter do |attribute| # rubocop:disable Performance/Count
23
- include_class = attribute.to.include_class
24
-
25
- next false if include_class.nil?
26
-
27
- if [Set, Array].include?(include_class)
28
- include_class.any? { |item| item <= Datory::Base }
29
- else
30
- include_class <= Datory::Base
31
- end
32
- end.size.positive?
33
- end
34
12
  end
35
13
  end
36
14
  end
@@ -10,26 +10,12 @@ module Featury
10
10
  @collection = collection
11
11
  end
12
12
 
13
- def names
14
- map(&:name)
13
+ def only_nested
14
+ Collection.new(filter(&:nested?))
15
15
  end
16
16
 
17
- def internal_names
18
- map { |attribute| attribute.to.name }
19
- end
20
-
21
- def include_class_exist?
22
- @include_class_exist ||= filter do |attribute| # rubocop:disable Performance/Count
23
- include_class = attribute.to.include_class
24
-
25
- next false if include_class.nil?
26
-
27
- if [Set, Array].include?(include_class)
28
- include_class.any? { |item| item <= Datory::Base }
29
- else
30
- include_class <= Datory::Base
31
- end
32
- end.size.positive?
17
+ def only_option
18
+ Collection.new(filter(&:option?))
33
19
  end
34
20
  end
35
21
  end
@@ -7,8 +7,20 @@ module Featury
7
7
 
8
8
  def initialize(name, **options)
9
9
  @name = name
10
+
11
+ @nested = options.delete(:nested) || false
12
+ @option = options.delete(:option) || false
13
+
10
14
  @options = options
11
15
  end
16
+
17
+ def nested?
18
+ @nested
19
+ end
20
+
21
+ def option?
22
+ @option
23
+ end
12
24
  end
13
25
  end
14
26
  end
@@ -5,7 +5,7 @@ module Featury
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc2"
8
+ PRE = "rc4"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: featury
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc2
4
+ version: 1.0.0.rc4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov