Class: Eac::DataTableHelper::Column::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/eac/data_table_helper/column.rb

Instance Method Summary collapse

Constructor Details

#initialize(node, path) ⇒ Node

Returns a new instance of Node.



31
32
33
34
# File 'lib/eac/data_table_helper/column.rb', line 31

def initialize(node, path)
  @node = node
  @path = path
end

Instance Method Details

#valueObject



36
37
38
39
40
41
42
# File 'lib/eac/data_table_helper/column.rb', line 36

def value
  return @node if @node.nil? || @path.empty?
  subpath = @path.dup
  n = subpath.shift
  return Node.new(@node.send(n), subpath).value if @node.respond_to?(n)
  raise "Instance of #{@node.class} does not respond to #{n}"
end