Class: ViewComponent::Storybook::Collections::ParametersCollection
- Inherits:
-
Object
- Object
- ViewComponent::Storybook::Collections::ParametersCollection
- Includes:
- ValidForStoryConcern
- Defined in:
- lib/view_component/storybook/collections/parameters_collection.rb
Instance Method Summary collapse
- #add(params, only: nil, except: nil) ⇒ Object
-
#for_all ⇒ Object
Parameters set for all stories.
-
#for_story(story_name) ⇒ Object
Parameters set for the story method.
-
#initialize ⇒ ParametersCollection
constructor
A new instance of ParametersCollection.
Methods included from ValidForStoryConcern
Constructor Details
#initialize ⇒ ParametersCollection
Returns a new instance of ParametersCollection.
9 10 11 12 |
# File 'lib/view_component/storybook/collections/parameters_collection.rb', line 9 def initialize @all_paramsters = {} @parameters = [] end |
Instance Method Details
#add(params, only: nil, except: nil) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/view_component/storybook/collections/parameters_collection.rb', line 14 def add(params, only: nil, except: nil) if only.nil? && except.nil? all_paramsters.merge!(params) else parameters << { params: params, only: only, except: except } end end |
#for_all ⇒ Object
Parameters set for all stories
23 24 25 |
# File 'lib/view_component/storybook/collections/parameters_collection.rb', line 23 def for_all all_paramsters end |
#for_story(story_name) ⇒ Object
Parameters set for the story method
28 29 30 31 32 |
# File 'lib/view_component/storybook/collections/parameters_collection.rb', line 28 def for_story(story_name) parameters.each_with_object({}) do |opts, accum| accum.merge!(opts[:params]) if valid_for_story?(story_name, **opts.slice(:only, :except)) end end |