Sha256: 35fe412036201b3714956aa24226b404a8e3660e646c86443cd6471a28410f41

Contents?: true

Size: 777 Bytes

Versions: 23

Compression:

Stored size: 777 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

    # Defines behavior for handling $or 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 Matchable.matcher(document, key, value).matches?(value)
          end
        end
        true
      end
    end
  end
end

Version data entries

23 entries across 21 versions & 6 rubygems

Version Path
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/matchable/and.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/matchable/and.rb
mongoid_rails4-4.0.0 lib/mongoid/matchable/and.rb