Class: Phlexi::Table::Components::DataColumn

Inherits:
Column
  • Object
show all
Defined in:
lib/phlexi/table/components/data_column.rb

Direct Known Subclasses

Base::DataColumn

Instance Attribute Summary

Attributes inherited from Base

#key, #options, #parent

Instance Method Summary collapse

Methods included from Concerns::DisplaysData

#data_cell_attributes

Methods included from Concerns::DisplaysHeader

#colspan, #header_cell_attributes

Methods included from Options::Alignment

#alignment

Methods included from Options::Labels

#label

Methods inherited from Base

#dom_id

Constructor Details

#initialize(&block) ⇒ DataColumn

Returns a new instance of DataColumn.



7
8
9
10
# File 'lib/phlexi/table/components/data_column.rb', line 7

def initialize(*, **, &block)
  super(*, **)
  @block = block
end

Instance Method Details

#data_cell(wrapped_object) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/phlexi/table/components/data_column.rb', line 16

def data_cell(wrapped_object)
  if @block
    @block.call(wrapped_object, key)
  else
    field = wrapped_object.field(key)
    field.send(:"#{field.inferred_field_component}_tag")
  end
end

#header_cellObject



12
13
14
# File 'lib/phlexi/table/components/data_column.rb', line 12

def header_cell
  SortableHeaderCell.new(label, sort_params:)
end