Class: ViewComponent::Storybook::Controls::CustomConfig
Instance Attribute Summary collapse
Instance Method Summary
collapse
#description, #initialize, #name, #prefix_param
Instance Attribute Details
#value_method_args ⇒ Object
Returns the value of attribute value_method_args.
7
8
9
|
# File 'lib/view_component/storybook/controls/custom_config.rb', line 7
def value_method_args
@value_method_args
end
|
Instance Method Details
#param(new_param = nil) ⇒ Object
17
18
19
20
|
# File 'lib/view_component/storybook/controls/custom_config.rb', line 17
def param(new_param = nil)
value_method_args.with_param_prefix(new_param) unless new_param.nil?
super(new_param)
end
|
#to_csf_params ⇒ Object
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/view_component/storybook/controls/custom_config.rb', line 22
def to_csf_params
validate!
value_method_args.controls.reduce({}) do |csf_params, control|
csf_params.deep_merge(control.to_csf_params)
end
end
|
#value_from_params(params) ⇒ Object
37
38
39
|
# File 'lib/view_component/storybook/controls/custom_config.rb', line 37
def value_from_params(params)
value_method_args.call(params)
end
|
#with_value(*args, **kwargs, &block) ⇒ Object
11
12
13
14
15
|
# File 'lib/view_component/storybook/controls/custom_config.rb', line 11
def with_value(*args, **kwargs, &block)
@value_method_args = MethodArgs::ControlMethodArgs.new(block, *args, **kwargs)
@value_method_args.with_param_prefix(param)
self
end
|