featury 1.0.0.rc2 → 1.0.0.rc3

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: ca75356ade329cfb662e46fa37ad0a80dbedb2deb0a58f23861f1e231d7e5425
4
+ data.tar.gz: 437cb00d9eb4eb07609df3f0c25ec2619af10c9264ed254d6c85f3eb0e527974
5
5
  SHA512:
6
- metadata.gz: 9a7e141130c232159477292ed179e8267fc50163f56b4c0d2cfe5b18238b2a7a498bbfd903d659bce143c447cb578c1ffa11e763a07988ecb3a6112286c17b71
7
- data.tar.gz: 24ebf4c4d1802856b78683917c5a717c4180823214e3dfbcbecefe30a53ae38f2558f46f09d7f18b395ebdd492091c6c8cc1fa2e3a61031c30e19d3bf2b0ba23
6
+ metadata.gz: 0d023c6922b92d82278313c4d6379a8e624d76f0e7972155558e5630516bdee079f24a096e1b565f71d6d98d7ecfc37c9238aa849d4efe68809c947e03a25ed5
7
+ data.tar.gz: cabb3d61981e2c44bce2c2d4ecbe1a5fa9d8857bedbd593060202368e08c5c9bbd4c1953ecadb9fbc4868124b49703c7a644e4d7fad293322f3ae4075b5c2d0b
data/README.md CHANGED
@@ -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 = "rc3"
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.rc3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov