Class: ActionView::Storybook::Controls::OptionsConfig
- Inherits:
-
ControlConfig
- Object
- ControlConfig
- ActionView::Storybook::Controls::OptionsConfig
- Defined in:
- lib/action_view/storybook/controls/options_config.rb
Constant Summary collapse
- TYPES =
%i[select multi-select radio inline-radio check inline-check].freeze
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#symbol_value ⇒ Object
readonly
Returns the value of attribute symbol_value.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from ControlConfig
Class Method Summary collapse
-
.inclusion_in(config) ⇒ Object
support the options being a Hash or an Array.
Instance Method Summary collapse
-
#initialize(type, param, options, default_value, name: nil) ⇒ OptionsConfig
constructor
A new instance of OptionsConfig.
- #value_from_param(param) ⇒ Object
Methods inherited from ControlConfig
Constructor Details
#initialize(type, param, options, default_value, name: nil) ⇒ OptionsConfig
Returns a new instance of OptionsConfig.
27 28 29 30 31 32 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 27 def initialize(type, param, , default_value, name: nil) super(param, default_value, name: name) @type = type @options = @symbol_value = default_value.is_a?(Symbol) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 21 def @options end |
#symbol_value ⇒ Object (readonly)
Returns the value of attribute symbol_value.
21 22 23 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 21 def symbol_value @symbol_value end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
21 22 23 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 21 def type @type end |
Class Method Details
.inclusion_in(config) ⇒ Object
support the options being a Hash or an Array. Storybook supports either.
9 10 11 12 13 14 15 16 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 9 def inclusion_in(config) case config. when Hash config..values when Array config. end end |
Instance Method Details
#value_from_param(param) ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/action_view/storybook/controls/options_config.rb', line 34 def value_from_param(param) if param.is_a?(String) && symbol_value param.to_sym else super(param) end end |