Sha256: a2e7bfcea9c5bf0d8a863e5726110b2f90d480f1c4dd2c57303280a8fae4f670

Contents?: true

Size: 757 Bytes

Versions: 13

Compression:

Stored size: 757 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

    # Defines behavior for handling $and expressions in embedded documents.
    class And < Default

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/matchable/and.rb
mongoid-7.0.12 lib/mongoid/matchable/and.rb
mongoid-7.0.11 lib/mongoid/matchable/and.rb
mongoid-7.0.10 lib/mongoid/matchable/and.rb
mongoid-7.0.8 lib/mongoid/matchable/and.rb
mongoid-7.0.7 lib/mongoid/matchable/and.rb
mongoid-7.0.6 lib/mongoid/matchable/and.rb
mongoid-7.0.5 lib/mongoid/matchable/and.rb
mongoid-7.0.4 lib/mongoid/matchable/and.rb
mongoid-7.0.3 lib/mongoid/matchable/and.rb
mongoid-7.0.2 lib/mongoid/matchable/and.rb
mongoid-7.0.1 lib/mongoid/matchable/and.rb
mongoid-7.0.0 lib/mongoid/matchable/and.rb