Class: ViewComponent::Storybook::Controls::DateConfig

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

Instance Attribute Summary

Attributes inherited from SimpleControlConfig

#default_value

Instance Method Summary collapse

Methods inherited from SimpleControlConfig

#to_csf_params

Methods inherited from ControlConfig

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

Constructor Details

#initialize(default_value, param: nil, name: nil, description: nil) ⇒ DateConfig

Returns a new instance of DateConfig.



7
8
9
# File 'lib/view_component/storybook/controls/date_config.rb', line 7

def initialize(default_value, param: nil, name: nil, description: nil)
  super(default_value, param: param, name: name, description: description)
end

Instance Method Details

#typeObject



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

def type
  :date
end

#value_from_params(params) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/view_component/storybook/controls/date_config.rb', line 15

def value_from_params(params)
  params_value = super(params)
  if params_value.is_a?(String)
    DateTime.iso8601(params_value)
  else
    params_value
  end
end