Class: ActionView::Storybook::Controls::ControlConfig

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Validations
Defined in:
lib/action_view/storybook/controls/control_config.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(param, value, name: nil) ⇒ ControlConfig

Returns a new instance of ControlConfig.



13
14
15
16
17
# File 'lib/action_view/storybook/controls/control_config.rb', line 13

def initialize(param, value, name: nil)
  @param = param
  @value = value
  @name = name || param.to_s.humanize.titlecase
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



9
10
11
# File 'lib/action_view/storybook/controls/control_config.rb', line 9

def name
  @name
end

#paramObject (readonly)

Returns the value of attribute param.



9
10
11
# File 'lib/action_view/storybook/controls/control_config.rb', line 9

def param
  @param
end

#valueObject (readonly)

Returns the value of attribute value.



9
10
11
# File 'lib/action_view/storybook/controls/control_config.rb', line 9

def value
  @value
end

Instance Method Details

#to_csf_paramsObject



19
20
21
22
23
24
# File 'lib/action_view/storybook/controls/control_config.rb', line 19

def to_csf_params
  {
    args: { param => csf_value },
    argTypes: { param => { control: csf_control_params, name: name } }
  }
end

#value_from_param(param) ⇒ Object



26
27
28
# File 'lib/action_view/storybook/controls/control_config.rb', line 26

def value_from_param(param)
  param
end