Class: HakumiComponents::Table::DisplayRows

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
app/components/hakumi_components/table/display_rows.rb

Constant Summary collapse

Row =
T.type_alias { HakumiComponents::Table::RowRecord }
DisplayRow =
T.type_alias { { row: Row, depth: Integer } }
PaginationValue =
T.type_alias { HakumiComponents::Table::Configs::Pagination::Value }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rows:, pagination:) ⇒ DisplayRows

Returns a new instance of DisplayRows.



19
20
21
22
# File 'app/components/hakumi_components/table/display_rows.rb', line 19

def initialize(rows:, pagination:)
  @rows = T.let(rows, T::Array[Row])
  @pagination = T.let(pagination, PaginationValue)
end

Class Method Details

.build(rows:, pagination:) ⇒ Object



14
15
16
# File 'app/components/hakumi_components/table/display_rows.rb', line 14

def self.build(rows:, pagination:)
  new(rows: rows, pagination: pagination).to_a
end

Instance Method Details

#to_aObject



25
26
27
28
# File 'app/components/hakumi_components/table/display_rows.rb', line 25

def to_a
  rows = flatten_tree(@rows)
  apply_pagination(rows)
end