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)


11
12
13
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 11

def label
  args[0]
end

#pathString

Returns:

  • (String)


16
17
18
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 16

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

#record_value(record) ⇒ Object



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

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)


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

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

  self
end

#value_cell_attributesHash

Returns:

  • (Hash)


39
40
41
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 39

def value_cell_attributes
  @value_cell_attributes ||= {}
end