Class: EacRailsUtils::DataTableHelper::Column

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/eac_rails_utils/data_table_helper/column.rb

Constant Summary collapse

EMPTY_VALUE =
'-'

Instance Method Summary collapse

Instance Method Details

#labelString

Returns:

  • (String)


13
14
15
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 13

def label
  args[0]
end

#pathString

Returns:

  • (String)


18
19
20
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 18

def path
  args[1].to_s.split('.')
end

#record_value(record) ⇒ Object



22
23
24
25
26
27
28
29
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 22

def record_value(record)
  v = ::EacRailsUtils::DataTableHelper::ColumnNode.new(record, path).value
  if v.present?
    block ? block.call(v) : v
  else
    EMPTY_VALUE
  end
end

#value_cell(attribute, value = nil, &block) ⇒ self

Parameters:

  • attribute (Symbol)
  • value (Proc, Object) (defaults to: nil)

Returns:

  • (self)


34
35
36
37
38
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 34

def value_cell(attribute, value = nil, &block)
  value_cell_attributes[attribute.to_sym] = block.if_present(value)

  self
end

#value_cell_attributesHash

Returns:

  • (Hash)


41
42
43
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 41

def value_cell_attributes
  @value_cell_attributes ||= {}
end