Skip to content

Commit 0503eff

Browse files
committed
Add feature and group descriptions to improve clarity
1 parent 18eff68 commit 0503eff

File tree

1 file changed

+42
-12
lines changed

1 file changed

+42
-12
lines changed

README.md

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,28 +90,28 @@ class User::OnboardingFeature < ApplicationFeature
9090

9191
condition ->(resources:) { resources.user.onboarding_awaiting? }
9292

93-
features :passage # => :user_onboarding_passage
93+
feature :passage, description: "User onboarding passage feature" # => :user_onboarding_passage
9494

95-
groups BillingFeature,
96-
PaymentSystemFeature
95+
group BillingFeature, description: "Billing functionality group"
96+
group PaymentSystemFeature, description: "Payment system functionality group"
9797
end
9898
```
9999

100100
```ruby
101101
class BillingFeature < ApplicationFeature
102102
prefix :billing
103103

104-
features :api, # => :billing_api
105-
:webhooks # => :billing_webhooks
104+
feature :api, description: "Billing API feature" # => :billing_api
105+
feature :webhooks, description: "Billing webhooks feature" # => :billing_webhooks
106106
end
107107
```
108108

109109
```ruby
110110
class PaymentSystemFeature < ApplicationFeature
111111
prefix :payment_system
112112

113-
features :api, # => :payment_system_api
114-
:webhooks # => :payment_system_webhooks
113+
feature :api, description: "Payment system API feature" # => :payment_system_api
114+
feature :webhooks, description: "Payment system webhooks feature" # => :payment_system_webhooks
115115
end
116116
```
117117

@@ -161,18 +161,48 @@ In the preceding example, there might be a scenario where the payment system is
161161
undergoing technical maintenance and therefore is temporarily shut down.
162162
Consequently, the onboarding process for new users will be halted until further notice.
163163

164+
#### Feature and Group descriptions
165+
166+
When defining features and groups, you can provide descriptions to add more context about what they do:
167+
168+
```ruby
169+
# Adding a feature with description
170+
feature :api, description: "External API integration"
171+
172+
# Adding a group with description
173+
group PaymentSystemFeature, description: "Payment processing functionality"
174+
```
175+
176+
These descriptions are preserved in the feature tree and can be accessed via the info method.
177+
164178
#### Information about features
165179

166180
```ruby
167181
info = User::OnboardingFeature.info
168182
```
169183

170184
```ruby
171-
info.actions # Feature actions (all, web) of the current class.
172-
info.resources # Feature resources of the current class.
173-
info.features # Feature flags of the current class.
174-
info.groups # Feature flag groups of the current class.
175-
info.tree # Tree of feature flags from the current class.
185+
# Feature actions information (all actions and web actions)
186+
info.actions.all # All actions: [:enabled?, :disabled?, :enable, :disable, :add]
187+
info.actions.web.all # Web actions: [:enabled?, :disabled?, :enable, :disable]
188+
189+
# Access specific web actions by their web: option name
190+
info.actions.web.enabled # Returns the method name (:enabled?) that was defined with `web: :enabled?`
191+
info.actions.web.enable # Returns the method name (:enable) that was defined with `web: :enable`
192+
info.actions.web.disable # Returns the method name (:disable) that was defined with `web: :disable`
193+
194+
# Feature resources information
195+
info.resources # Feature resources of the current class.
196+
197+
# Feature flags information (with descriptions)
198+
info.features # Feature flags of the current class with their names and descriptions.
199+
200+
# Feature groups information (with descriptions)
201+
info.groups # Feature groups of the current class with their class references and descriptions.
202+
203+
# Complete feature tree (features and nested groups)
204+
info.tree.features # Direct features of the current class.
205+
info.tree.groups # Features from nested groups.
176206
```
177207

178208
## Contributing

0 commit comments

Comments
 (0)