Sha256: 1cdf03e41b313888df2581f751959001b1b38009c65ba0f5d8b4c611cfdf9754

Contents?: true

Size: 864 Bytes

Versions: 23

Compression:

Stored size: 864 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

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

Version data entries

23 entries across 21 versions & 6 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/lib/mongoid/matchable/or.rb
mongoid-5.1.0 lib/mongoid/matchable/or.rb
tdiary-4.2.1 vendor/bundle/ruby/2.3.0/gems/mongoid-5.0.2/lib/mongoid/matchable/or.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.2/lib/mongoid/matchable/or.rb
tdiary-4.2.1 vendor/bundle/ruby/2.2.0/gems/mongoid-5.0.1/lib/mongoid/matchable/or.rb
mongoid-5.0.2 lib/mongoid/matchable/or.rb
mongoid-5.0.1 lib/mongoid/matchable/or.rb
mongoid-5.0.0 lib/mongoid/matchable/or.rb
mongoid-5.0.0.rc0 lib/mongoid/matchable/or.rb
mongoid-5.0.0.beta lib/mongoid/matchable/or.rb
mongoid-4.0.2 lib/mongoid/matchable/or.rb
mongoid-4.0.1 lib/mongoid/matchable/or.rb
mongoid-4.0.0 lib/mongoid/matchable/or.rb
mongoid-4.0.0.rc2 lib/mongoid/matchable/or.rb
mongoid-4.0.0.rc1 lib/mongoid/matchable/or.rb
mongoid-4.0.0.beta2 lib/mongoid/matchable/or.rb
mongoid-4.0.0.beta1 lib/mongoid/matchable/or.rb
mongoid-4.0.0.alpha2 lib/mongoid/matchable/or.rb
mongoid-4.0.0.alpha1 lib/mongoid/matchable/or.rb
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/matchable/or.rb