Class: JSONPath::Nodes::CodeNode

Inherits:
PathNode
  • Object
show all
Defined in:
lib/jsonpath/nodes.rb

Direct Known Subclasses

ExprNode, FilterNode

Instance Method Summary collapse

Methods inherited from PathNode

#recurse, #traverse, #traversing_descendants?

Instance Method Details

#codeObject



157
158
159
160
161
162
# File 'lib/jsonpath/nodes.rb', line 157

def code
  @code ||= begin
    text = template_code.text_value
    text.gsub('@', '(obj)').gsub('\\(obj)', '@')
  end
end

#execute(obj) ⇒ Object



164
165
166
# File 'lib/jsonpath/nodes.rb', line 164

def execute(obj)
  eval(code, binding)
end