Sha256: c9a4d5d48b64eb92a18b10f429a9f363d0aac4fbce49f042928a5005a39fcebe

Contents?: true

Size: 805 Bytes

Versions: 171

Compression:

Stored size: 805 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Matchers #:nodoc:

    # 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?("$and" => [ { 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 Strategies.matcher(document, key, value).matches?(value)
          end
        end
        true
      end
    end
  end
end

Version data entries

171 entries across 79 versions & 4 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb
mongoid-2.8.1 lib/mongoid/matchers/and.rb
mongoid-2.8.0 lib/mongoid/matchers/and.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/and.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/and.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/and.rb