Module: Siren::JsonQuery::BooleanFilter

Defined in:
lib/siren/json_query_nodes.rb

Instance Method Summary collapse

Instance Method Details

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



112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/siren/json_query_nodes.rb', line 112

def value(list, root, symbols, current = nil)
  results, visited = [], Set.new
  
  visitor = lambda do |visitee|
    return unless visited.add?(visitee)
    Siren.each(visitee) do |index, value|
      begin
        results << value if boolean_expression.value(root, symbols, value)
      rescue
      end
      visitor.call(value) if recursive.text_value == '..'
    end
  end
  
  visitor.call(list)
  results
end