Class: ViewComponent::Storybook::Controls::Object

Inherits:
SimpleControl show all
Defined in:
lib/view_component/storybook/controls/object.rb

Instance Attribute Summary

Attributes inherited from Control

#default, #description, #name, #param

Instance Method Summary collapse

Methods inherited from SimpleControl

#initialize, #to_csf_params

Methods inherited from Control

#initialize, #to_csf_params

Constructor Details

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

Instance Method Details

#parse_param_value(value) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/view_component/storybook/controls/object.rb', line 11

def parse_param_value(value)
  if value.is_a?(String)
    parsed_json = JSON.parse(value)
    if parsed_json.is_a?(Array)
      parsed_json.map do |item|
        item.is_a?(Hash) ? item.deep_symbolize_keys : item
      end
    else
      parsed_json.deep_symbolize_keys
    end
  else
    value
  end
end

#typeObject



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

def type
  :object
end