Class: RPath::Expression Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/rpath/expressions.rb

Overview

This class is abstract.

An RPath expression, given a graph, produces a value: a vertex, a vertex array, an attribute value, or a vertex’s content.

Instance Method Summary collapse

Instance Method Details

#eval(graph, adapter = nil) ⇒ Object

Evaluates the expression on a graph

Parameters:

  • graph (Object)
  • adapter (RPath::Adapter, Symbol, nil) (defaults to: nil)

    An Adapter instance, the id symbol given when the adapter was registered with RPath.use, or nil if the adapter should be inferred.

Returns:

  • (Object)

Raises:

  • (RuntimeError)

    The adapter can’t be determined

  • (ArgumentError)

    adapter is not an Adapter, Symbol, or nil

See Also:



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/rpath/expressions.rb', line 22

def eval(graph, adapter = nil)
  adapter = case adapter
  when RPath::Adapter
    adapter
  when Symbol
    Registry.find adapter
  when nil
    Registry.infer graph
  else
    raise ArgumentError, "Adapter must be an RPath::Adapter, Symbol, or nil"
  end

  unless adapter
    raise "Can't determine adapter"
  end

  do_eval graph, adapter
end