Class: ViewComponent::Storybook::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/view_component/storybook/story.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, parameters, controls) ⇒ Story

Returns a new instance of Story.



8
9
10
11
12
13
# File 'lib/view_component/storybook/story.rb', line 8

def initialize(id, name, parameters, controls)
  @id = id
  @name = name
  @parameters = parameters
  @controls = controls
end

Instance Attribute Details

#controlsObject (readonly)

Returns the value of attribute controls.



6
7
8
# File 'lib/view_component/storybook/story.rb', line 6

def controls
  @controls
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/view_component/storybook/story.rb', line 6

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/view_component/storybook/story.rb', line 6

def name
  @name
end

#parametersObject (readonly)

Returns the value of attribute parameters.



6
7
8
# File 'lib/view_component/storybook/story.rb', line 6

def parameters
  @parameters
end

Instance Method Details

#to_csf_paramsObject



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

def to_csf_params
  csf_params = { name: name, parameters: { server: { id: id } } }
  csf_params.deep_merge!(parameters: parameters) if parameters.present?
  controls.each do |control|
    csf_params.deep_merge!(control.to_csf_params)
  end
  csf_params
end