featury 1.0.0.rc3 → 1.0.0.rc5

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: ca75356ade329cfb662e46fa37ad0a80dbedb2deb0a58f23861f1e231d7e5425
4
- data.tar.gz: 437cb00d9eb4eb07609df3f0c25ec2619af10c9264ed254d6c85f3eb0e527974
3
+ metadata.gz: 4109a155154dfe53461c79450a8a458f75c310cd4059c7aba50f5ccf44934152
4
+ data.tar.gz: ebe758de6245459700faeded72efe9537b27b7b4a1f63bd958c8cea28bbb1a01
5
5
  SHA512:
6
- metadata.gz: 0d023c6922b92d82278313c4d6379a8e624d76f0e7972155558e5630516bdee079f24a096e1b565f71d6d98d7ecfc37c9238aa849d4efe68809c947e03a25ed5
7
- data.tar.gz: cabb3d61981e2c44bce2c2d4ecbe1a5fa9d8857bedbd593060202368e08c5c9bbd4c1953ecadb9fbc4868124b49703c7a644e4d7fad293322f3ae4075b5c2d0b
6
+ metadata.gz: bf21d12a7491f66f223624615b9d56fc1006e009d855513a32eeda2f4e07cc359523a4dd62d36ff9845356bf8b340afba6f9f9813599784a7a528170cba29f3f
7
+ data.tar.gz: bbe7138eb5e70b8dc4a0220b683717f8f1b53ac5e1c8f85504ec2e78b6f55c324780e5ce3cca705b11cd8b06cb23ead7ec24480b284be1ad8e5271ae1062a18e
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
  ```
@@ -116,6 +116,17 @@ UserFeature::Onboarding.enable(user:) # => true
116
116
  UserFeature::Onboarding.disable(user:) # => false
117
117
  ```
118
118
 
119
+ You can also use the `with` method to pass arguments if needed.
120
+
121
+ ```ruby
122
+ feature = UserFeature::Onboarding.with(user:)
123
+
124
+ feature.enabled? # => true
125
+ feature.disabled? # => false
126
+ feature.enable # => true
127
+ feature.disable # => false
128
+ ```
129
+
119
130
  If one of the feature flags is turned off, for example,
120
131
  through your automation, then the main feature class will
121
132
  return `false` when asked "is it enabled?".
@@ -21,7 +21,7 @@ module Featury
21
21
  @model_class.const_set(Builder::SERVICE_CLASS_NAME, class_sample)
22
22
  end
23
23
 
24
- def create_service_class # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
24
+ def create_service_class # rubocop:disable Metrics/MethodLength, Metrics/AbcSize,Metrics/CyclomaticComplexity
25
25
  collection_of_resources = @collection_of_resources
26
26
 
27
27
  Class.new(Featury::Service::Builder) do
@@ -56,7 +56,7 @@ module Featury
56
56
  end
57
57
  end
58
58
 
59
- def check_features
59
+ def check_features # rubocop:disable Metrics/AbcSize
60
60
  options = inputs.collection_of_resources.only_option.to_h do |resource|
61
61
  [resource.name, inputs.public_send(resource.name)]
62
62
  end
@@ -65,7 +65,7 @@ module Featury
65
65
  inputs.action.block.call(features: inputs.collection_of_features.list, **options)
66
66
  end
67
67
 
68
- def check_groups
68
+ def check_groups # rubocop:disable Metrics/AbcSize
69
69
  arguments = inputs.collection_of_resources.only_nested.to_h do |resource|
70
70
  [resource.name, inputs.public_send(resource.name)]
71
71
  end
@@ -10,6 +10,8 @@ module Featury
10
10
 
11
11
  context = send(:new)
12
12
 
13
+ arguments.merge!(@with_arguments) if @with_arguments.is_a?(Hash)
14
+
13
15
  _call!(context, action, **arguments)
14
16
  end
15
17
 
@@ -17,6 +19,12 @@ module Featury
17
19
  collection_of_actions.names.include?(method_name) || super
18
20
  end
19
21
 
22
+ def with(arguments = {})
23
+ @with_arguments = arguments
24
+
25
+ self
26
+ end
27
+
20
28
  private
21
29
 
22
30
  def _call!(context, action, **arguments)
@@ -5,7 +5,7 @@ module Featury
5
5
  MAJOR = 1
6
6
  MINOR = 0
7
7
  PATCH = 0
8
- PRE = "rc3"
8
+ PRE = "rc5"
9
9
 
10
10
  STRING = [MAJOR, MINOR, PATCH, PRE].compact.join(".")
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: featury
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc3
4
+ version: 1.0.0.rc5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-06-22 00:00:00.000000000 Z
11
+ date: 2024-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport