Class: EacRailsUtils::DataTableHelper::Column

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

Defined Under Namespace

Classes: Node

Constant Summary collapse

EMPTY_VALUE =
'-'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, path, block) ⇒ Column

Returns a new instance of Column.


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

def initialize(label, path, block)
  @label = label
  @path = path.to_s.split('.')
  @block = block
end

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.


8
9
10
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 8

def label
  @label
end

Instance Method Details

#record_value(record) ⇒ Object


16
17
18
19
20
21
22
23
# File 'app/helpers/eac_rails_utils/data_table_helper/column.rb', line 16

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