Sha256: fc3879b9d6686bfa6112bcd69b319f08d2c28a473610b2d8c62f461ba0604e06
Contents?: true
Size: 1.09 KB
Versions: 40
Compression:
Stored size: 1.09 KB
Contents
module Mongoid module Matcher # @api private module ElemMatch module_function def matches?(exists, value, condition) unless Hash === condition raise Errors::InvalidQuery, "$elemMatch requires a Hash operand: #{Errors::InvalidQuery.truncate_expr(condition)}" end if Array === value && !value.empty? value.any? do |v| ElemMatchExpression.matches?(v, condition) end else # Validate the condition is valid, even though we will never attempt # matching it. condition.each do |k, v| k = k.to_s if k.start_with?('$') begin ExpressionOperator.get(k) rescue Mongoid::Errors::InvalidExpressionOperator begin FieldOperator.get(k) rescue Mongoid::Errors::InvalidFieldOperator => exc raise Mongoid::Errors::InvalidElemMatchOperator.new(exc.operator) end end end end false end end end end end
Version data entries
40 entries across 40 versions & 1 rubygems