module Graphoid::Queries::Processor

Public Class Methods

execute(scope, object) click to toggle source
# File lib/graphoid/queries/processor.rb, line 7
def execute(scope, object)
  object.each { |key, value| scope = process(scope, value, key) }
  scope
end
execute_array(scope, list, action) click to toggle source
# File lib/graphoid/queries/processor.rb, line 12
def execute_array(scope, list, action)
  if action == 'OR'
    scope = Graphoid.driver.execute_or(scope, list)
  else
    list.each { |object| scope = execute(scope, object) }
  end
  scope
end
parse_order(scope, order) click to toggle source
# File lib/graphoid/queries/processor.rb, line 36
def parse_order(scope, order)
  fields = Attribute.fieldnames_of(scope)
  Utils.underscore(order, fields)
end
process(scope, value, key = nil) click to toggle source
# File lib/graphoid/queries/processor.rb, line 21
def process(scope, value, key = nil)
  if key && %w[OR AND].exclude?(key)
    operation = Operation.new(scope, key, value)
    filter = operation.resolve
    return Graphoid.driver.execute_and(scope, filter)
  end

  if operation.nil? || operation.type == :attribute
    return execute(scope, value) if value.is_a?(Hash)
    if value.is_a?(Array) && %w[in nin].exclude?(operation&.operator)
      return execute_array(scope, value, key)
    end
  end
end