Class: ViewComponent::Storybook::Controls::BooleanConfig

Inherits:
SimpleControlConfig show all
Defined in:
lib/view_component/storybook/controls/boolean_config.rb

Constant Summary collapse

BOOLEAN_VALUES =
[true, false].freeze

Instance Attribute Summary

Attributes inherited from SimpleControlConfig

#default_value

Instance Method Summary collapse

Methods inherited from SimpleControlConfig

#initialize, #to_csf_params

Methods inherited from ControlConfig

#description, #initialize, #name, #param, #prefix_param, #to_csf_params

Constructor Details

This class inherits a constructor from ViewComponent::Storybook::Controls::SimpleControlConfig

Instance Method Details

#typeObject



11
12
13
# File 'lib/view_component/storybook/controls/boolean_config.rb', line 11

def type
  :boolean
end

#value_from_params(params) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/view_component/storybook/controls/boolean_config.rb', line 15

def value_from_params(params)
  params_value = super(params)
  if params_value.is_a?(String) && params_value.present?
    case params_value
    when "true"
      true
    when "false"
      false
    end
  else
    params_value
  end
end