Class: JSONPath::Nodes::FilterNode

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

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Methods inherited from CodeNode

#code, #execute

Methods inherited from PathNode

#recurse, #traverse, #traversing_descendants?

Instance Method Details

#descend(*objects) ⇒ Object



195
196
197
198
199
200
201
202
203
204
205
206
207
# File 'lib/jsonpath/nodes.rb', line 195

def descend(*objects)
  results = []
  traverse(objects) do |set|
    next unless set.is_a?(Array) || set.is_a?(Hash)
    values = set.is_a?(Array) ? set : set.values
    values.each do |obj|
      if execute(obj)
        results << obj
      end
    end
  end
  results
end