Class: Moxml::XPath::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/moxml/xpath/context.rb

Overview

Class used as the context for compiled XPath Procs.

The binding of this class is used for the binding of Procs compiled by Compiler. Not using a specific binding would result in the procs using the binding of Moxml::XPath::Compiler#compile, which could lead to race conditions.

Instance Method Summary collapse

Constructor Details

#initializeContext

Returns a new instance of Context.



13
14
15
# File 'lib/moxml/xpath/context.rb', line 13

def initialize
  @binding = binding
end

Instance Method Details

#evaluate(string) ⇒ Proc

Evaluates a Ruby code string in this context’s binding.

Parameters:

  • string (String)

    Ruby code to evaluate

Returns:

  • (Proc)


21
22
23
# File 'lib/moxml/xpath/context.rb', line 21

def evaluate(string)
  @binding.eval(string)
end