Class: DesignSystem::Components::SummaryListRowBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/design_system/components/summary_list.rb

Overview

This class provides a builder for a summary list row.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSummaryListRowBuilder

Returns a new instance of SummaryListRowBuilder.



31
32
33
34
35
36
37
# File 'lib/design_system/components/summary_list.rb', line 31

def initialize
  @row = {
    key: {},
    values: [],
    actions: []
  }
end

Instance Attribute Details

#rowObject (readonly)

Returns the value of attribute row.



29
30
31
# File 'lib/design_system/components/summary_list.rb', line 29

def row
  @row
end

Instance Method Details

#add_action(content, options = {}) ⇒ Object

Use this method to add an action to a row and add link via options hash



50
51
52
# File 'lib/design_system/components/summary_list.rb', line 50

def add_action(content, options = {})
  @row[:actions] << { content: content.to_s, options: }
end

#add_key(content, options = {}) ⇒ Object

Required element for a row in the summary list



40
41
42
# File 'lib/design_system/components/summary_list.rb', line 40

def add_key(content, options = {})
  @row[:key] = { content: content.to_s, options: }
end

#add_value(content, options = {}) ⇒ Object

Use this method to add multiple values in a single row



45
46
47
# File 'lib/design_system/components/summary_list.rb', line 45

def add_value(content, options = {})
  @row[:values] << { content: content.to_s, options: }
end