Skip to content

Commit 25bc3b3

Browse files
committed
Add resource names to Featury::Info::Result
**Changes:** - Introduced `names` method in `Collection` for retrieving all resource names. - Updated `Featury::Info::DSL` to include resource names in the `Result` initialization. - Extended `Featury::Info::Result` to accommodate the new `resources` attribute. - Added a corresponding spec to validate resource inclusion. This enhances functionality by providing easy access to resource names in the feature info result.
1 parent 6999246 commit 25bc3b3

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

lib/featury/info/dsl.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ def self.included(base)
88
end
99

1010
module ClassMethods
11-
def info
11+
def info # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
1212
Featury::Info::Result.new(
1313
actions: Featury::Info::Result::Actions.new(collection_of_actions),
14+
resources: collection_of_resources.names,
1415
features: collection_of_features.full_names,
1516
groups: collection_of_groups.map(&:group),
1617
tree: collection_of_features.full_names.concat(

lib/featury/info/result.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,14 @@ def initialize(collection_of_actions)
2828
end
2929

3030
attr_reader :actions,
31+
:resources,
3132
:features,
3233
:groups,
3334
:tree
3435

35-
def initialize(actions:, features:, groups:, tree:)
36+
def initialize(actions:, resources:, features:, groups:, tree:)
3637
@actions = actions
38+
@resources = resources
3739
@features = features
3840
@groups = groups
3941
@tree = tree

lib/featury/resources/collection.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ def only_nested
1717
def only_option
1818
Collection.new(filter(&:option?))
1919
end
20+
21+
def names
22+
map(&:name)
23+
end
2024
end
2125
end
2226
end

spec/examples/usual/example1/main_feature_spec.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,13 @@
671671
it { expect(perform.actions.web.enable).to eq(:enable) }
672672
it { expect(perform.actions.web.disable).to eq(:disable) }
673673

674+
it do
675+
expect(perform.resources).to contain_exactly(
676+
:record,
677+
:user
678+
)
679+
end
680+
674681
it do
675682
expect(perform.features).to contain_exactly(
676683
:usual_example_1_a,

0 commit comments

Comments
 (0)