Class: ViewComponent::Storybook::Controls::ControlConfig

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

Direct Known Subclasses

CustomConfig, SimpleControlConfig

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ControlConfig.



11
12
13
14
15
# File 'lib/view_component/storybook/controls/control_config.rb', line 11

def initialize(param: nil, name: nil, description: nil)
  @param = param
  @name = name
  @description = description
end

Instance Method Details

#description(new_description = nil) ⇒ Object



26
27
28
29
30
31
# File 'lib/view_component/storybook/controls/control_config.rb', line 26

def description(new_description = nil)
  return @description if new_description.nil?

  @description = new_description
  self
end

#name(new_name = nil) ⇒ Object



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

def name(new_name = nil)
  if new_name.nil?
    @name ||= param.to_s.humanize.titlecase
  else
    @name = new_name
    self
  end
end

#param(new_param = nil) ⇒ Object



33
34
35
36
37
38
# File 'lib/view_component/storybook/controls/control_config.rb', line 33

def param(new_param = nil)
  return @param if new_param.nil?

  @param = new_param
  self
end

#prefix_param(prefix) ⇒ Object



40
41
42
# File 'lib/view_component/storybook/controls/control_config.rb', line 40

def prefix_param(prefix)
  param("#{prefix}__#{@param}".to_sym)
end

#to_csf_paramsObject

Raises:

  • (NotImplementedError)


44
45
46
47
48
# File 'lib/view_component/storybook/controls/control_config.rb', line 44

def to_csf_params
  # :nocov:
  raise NotImplementedError
  # :nocov:
end

#value_from_params(params) ⇒ Object

Raises:

  • (NotImplementedError)


50
51
52
53
54
# File 'lib/view_component/storybook/controls/control_config.rb', line 50

def value_from_params(params)
  # :nocov:
  raise NotImplementedError
  # :nocov:
end