Class: DesignSystem::Components::SummaryList

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSummaryList

Returns a new instance of SummaryList.



8
9
10
# File 'lib/design_system/components/summary_list.rb', line 8

def initialize
  @rows = []
end

Instance Attribute Details

#rowsObject

Returns the value of attribute rows.



6
7
8
# File 'lib/design_system/components/summary_list.rb', line 6

def rows
  @rows
end

Instance Method Details

#add_row(*args, key: nil, value: nil) {|row_builder| ... } ⇒ Object

Add a new row to the summary list. Use this method to add rows containing single key-value pair

Yields:

  • (row_builder)


14
15
16
17
18
19
20
21
22
23
# File 'lib/design_system/components/summary_list.rb', line 14

def add_row(*args, key: nil, value: nil)
  key, value = args if args.any?

  row_builder = SummaryListRowBuilder.new
  row_builder.add_key(key) if key
  row_builder.add_value(value) if value

  yield(row_builder) if block_given?
  @rows << row_builder.row
end