Module: Siren::JsonQuery::RecursiveAccess

Defined in:
lib/siren/json_query_nodes.rb

Instance Method Summary collapse

Instance Method Details

#value(object, root, symbols, current = nil) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/siren/json_query_nodes.rb', line 53

def value(object, root, symbols, current = nil)
  name = elements[1].text_value
  results, visited = [], Set.new
  
  visitor = lambda do |visitee|
    return unless visited.add?(visitee)
    Siren.each(visitee) do |index, value|
      results << value if index == name
      visitor.call(value)
    end
  end
  
  visitor.call(object)
  results
end