Class: Polaris::DataTable::ColumnComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/polaris/data_table/column_component.rb

Constant Summary collapse

SORT_DEFAULT =
false
SORT_OPTIONS =
[false, :asc, :desc]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block) ⇒ ColumnComponent

Returns a new instance of ColumnComponent.



7
8
9
10
11
12
13
14
15
# File 'app/components/polaris/data_table/column_component.rb', line 7

def initialize(title, numeric: false, total: nil, sorted: SORT_DEFAULT, sort_url: nil, **system_arguments, &block)
  @title = title
  @numeric = numeric
  @total = total
  @sorted = fetch_or_fallback(SORT_OPTIONS, sorted, SORT_DEFAULT)
  @sort_url = sort_url
  @block = block
  @system_arguments = system_arguments
end

Instance Attribute Details

#numericObject (readonly)

Returns the value of attribute numeric.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def numeric
  @numeric
end

#sort_urlObject (readonly)

Returns the value of attribute sort_url.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def sort_url
  @sort_url
end

#sortedObject (readonly)

Returns the value of attribute sorted.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def sorted
  @sorted
end

#system_argumentsObject (readonly)

Returns the value of attribute system_arguments.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def system_arguments
  @system_arguments
end

#titleObject (readonly)

Returns the value of attribute title.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def title
  @title
end

#totalObject (readonly)

Returns the value of attribute total.



5
6
7
# File 'app/components/polaris/data_table/column_component.rb', line 5

def total
  @total
end

Instance Method Details

#call(row) ⇒ Object



17
18
19
# File 'app/components/polaris/data_table/column_component.rb', line 17

def call(row)
  @block.call(row)
end