Sha256: 500a2083cc737e26b409dcb70ba0c5455388fab15ae8fdff479cd71259403d5f
Contents?: true
Size: 762 Bytes
Versions: 10
Compression:
Stored size: 762 Bytes
Contents
# encoding: utf-8 module Mongoid module Matchable class ElemMatch < Default # Return true if a given predicate matches a sub document entirely # # @example Do the values match? # matcher.matches?({"$elemMatch" => {"a" => 1, "b" => 2}}) # # @param [ Hash ] value The values to check. # # @return [ true, false ] If the values match. def matches?(value) if !@attribute.is_a?(Array) || !value.kind_of?(Hash) || !value["$elemMatch"].kind_of?(Hash) return false end return @attribute.any? do |sub_document| value["$elemMatch"].all? do |k, v| Matchable.matcher(sub_document, k, v).matches?(v) end end end end end end
Version data entries
10 entries across 9 versions & 2 rubygems