Sha256: 1693ad13726060c1e4ceef0609163455fe606e91ef8cc68d15f763ecf8315134

Contents?: true

Size: 864 Bytes

Versions: 32

Compression:

Stored size: 864 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchers

    # 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 &&= Strategies.matcher(document, key, value).matches?(value)
            break unless res
          end
          return res if res
        end
        return false
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
mongoid-3.1.7 lib/mongoid/matchers/or.rb
mongoid-3.1.6 lib/mongoid/matchers/or.rb
mongoid-3.1.5 lib/mongoid/matchers/or.rb
mongoid-3.1.4 lib/mongoid/matchers/or.rb
mongoid-3.1.3 lib/mongoid/matchers/or.rb
mongoid-3.1.2 lib/mongoid/matchers/or.rb
mongoid-3.0.23 lib/mongoid/matchers/or.rb
mongoid-3.1.1 lib/mongoid/matchers/or.rb
mongoid-3.1.0 lib/mongoid/matchers/or.rb
mongoid-3.0.22 lib/mongoid/matchers/or.rb
mongoid-3.0.21 lib/mongoid/matchers/or.rb
mongoid-3.0.20 lib/mongoid/matchers/or.rb
mongoid-3.0.19 lib/mongoid/matchers/or.rb
mongoid-3.0.18 lib/mongoid/matchers/or.rb
mongoid-3.0.17 lib/mongoid/matchers/or.rb
sunrise-cms-0.5.0.rc1 vendor/bundle/ruby/1.9.1/gems/mongoid-3.0.16/lib/mongoid/matchers/or.rb
mongoid-3.0.16 lib/mongoid/matchers/or.rb
mongoid-3.0.15 lib/mongoid/matchers/or.rb
mongoid-3.0.14 lib/mongoid/matchers/or.rb
mongoid-3.0.13 lib/mongoid/matchers/or.rb