Sha256: 9a54de6bde8dcef524a86cbbd4cce65fea1836afde9fec2e5a45bc17fc087a20

Contents?: true

Size: 809 Bytes

Versions: 6

Compression:

Stored size: 809 Bytes

Contents

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

    # 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|
          key = condition.keys.first
          value = condition.values.first
          if Strategies.matcher(document, key, value).matches?(value)
            return true
          end
        end
        return false
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
mongoid-braxton-2.0.2 lib/mongoid/matchers/or.rb
mongoid-2.0.2 lib/mongoid/matchers/or.rb
mongoid-2.0.1 lib/mongoid/matchers/or.rb
mongoid-2.0.0 lib/mongoid/matchers/or.rb
mongoid-2.0.0.rc.8 lib/mongoid/matchers/or.rb
mongoid-2.0.0.rc.7 lib/mongoid/matchers/or.rb