module Mongoid::Matcher::Nor

@api private

Public Instance Methods

matches?(document, expr) click to toggle source
# File lib/mongoid/matcher/nor.rb, line 6
                def matches?(document, expr)
  unless expr.is_a?(Array)
    raise Errors::InvalidQuery, "$nor argument must be an array: #{Errors::InvalidQuery.truncate_expr(expr)}"
  end

  if expr.empty?
    raise Errors::InvalidQuery, "$nor argument must be a non-empty array: #{Errors::InvalidQuery.truncate_expr(expr)}"
  end

  expr.each do |sub_expr|
    if Expression.matches?(document, sub_expr)
      return false
    end
  end

  expr.any?
end