Class: Layouts::SettingsSectionComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/layouts/settings_section_component.rb

Instance Method Summary collapse

Constructor Details

#initialize(heading, description: nil, id: nil, testid: nil, options: {}) ⇒ SettingsSectionComponent

Returns a new instance of SettingsSectionComponent.

Parameters:

  • heading (String)
  • description (String) (defaults to: nil)
  • id (String) (defaults to: nil)
  • testid (String) (defaults to: nil)
  • options (Hash) (defaults to: {})


10
11
12
13
14
15
16
# File 'app/components/layouts/settings_section_component.rb', line 10

def initialize(heading, description: nil, id: nil, testid: nil, options: {})
  @heading = heading
  @description = description
  @id = id
  @testid = testid
  @options = options
end

Instance Method Details

#options_attrsObject



22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/components/layouts/settings_section_component.rb', line 22

def options_attrs
  data = @options[:data] || {}
  data[:testid] ||= @testid

  attrs = {
    class: [@options[:class]].flatten.compact,
    data: data
  }
  attrs[:id] = @id if @id

  @options.merge(attrs)
end