Sha256: 5201ec1e0bf3255b93a2fb0e21d76d9fe8ea8d76dcc782f4e8418541ffc8654f

Contents?: true

Size: 874 Bytes

Versions: 13

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true
# encoding: utf-8

module Mongoid
  module Matchable

    # Defines behavior for handling $or expressions in embedded documents.
    class Or < Default

      # Does the supplied query match the attribute?
      #
      # @example Does this match?
      #   matcher._matches?("$or" => [ { field => value } ])
      #
      # @param [ Array ] conditions The or expression.
      #
      # @return [ true, false ] True if matches, false if not.
      #
      # @since 2.0.0.rc.7
      def _matches?(conditions)
        conditions.each do |condition|
          res = true
          condition.keys.each do |k|
            key = k
            value = condition[k]
            res &&= document._matches?(key => value)
            break unless res
          end
          return res if res
        end
        return false
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 2 rubygems

Version Path
mongoid-7.1.11 lib/mongoid/matchable/or.rb
mongoid-7.1.10 lib/mongoid/matchable/or.rb
mongoid-7.1.9 lib/mongoid/matchable/or.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/mongoid-7.1.7/lib/mongoid/matchable/or.rb
mongoid-7.1.8 lib/mongoid/matchable/or.rb
mongoid-7.1.7 lib/mongoid/matchable/or.rb
mongoid-7.1.6 lib/mongoid/matchable/or.rb
mongoid-7.1.5 lib/mongoid/matchable/or.rb
mongoid-7.1.4 lib/mongoid/matchable/or.rb
mongoid-7.1.2 lib/mongoid/matchable/or.rb
mongoid-7.1.1 lib/mongoid/matchable/or.rb
mongoid-7.1.0 lib/mongoid/matchable/or.rb
mongoid-7.1.0.rc0 lib/mongoid/matchable/or.rb