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 +4 -4
- data/README.md +15 -6
- data/lib/featury/actions/action.rb +1 -1
- data/lib/featury/actions/dsl.rb +4 -1
- data/lib/featury/actions/service/builder.rb +1 -0
- data/lib/featury/actions/service/factory.rb +9 -3
- data/lib/featury/conditions/collection.rb +0 -22
- data/lib/featury/resources/collection.rb +4 -18
- data/lib/featury/resources/resource.rb +12 -0
- 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: ca75356ade329cfb662e46fa37ad0a80dbedb2deb0a58f23861f1e231d7e5425
|
4
|
+
data.tar.gz: 437cb00d9eb4eb07609df3f0c25ec2619af10c9264ed254d6c85f3eb0e527974
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/featury/actions/dsl.rb
CHANGED
@@ -18,7 +18,10 @@ module Featury
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def action(name)
|
21
|
-
collection_of_actions << Action.new(
|
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
|
-
|
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.
|
64
|
-
[
|
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
|
14
|
-
|
13
|
+
def only_nested
|
14
|
+
Collection.new(filter(&:nested?))
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
|
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
|
data/lib/featury/version.rb
CHANGED