Class: Eac::DataTableHelper::Column

Inherits:
Object
  • Object
show all
Defined in:
lib/eac/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.



9
10
11
12
13
# File 'lib/eac/data_table_helper/column.rb', line 9

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.



7
8
9
# File 'lib/eac/data_table_helper/column.rb', line 7

def label
  @label
end

Instance Method Details

#record_value(r) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/eac/data_table_helper/column.rb', line 15

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