Sha256: 92871d9d52adc89e0833e875cf70b3faa7a3c71f4435ef914040398a9e9f8148

Contents?: true

Size: 787 Bytes

Versions: 4

Compression:

Stored size: 787 Bytes

Contents

# encoding: utf-8
require "mongoid/matchers/strategies"

module Mongoid #:nodoc:

  # This module contains all the behavior for ruby implementations of MongoDB
  # selectors.
  module Matchers

    # Determines if this document has the attributes to match the supplied
    # MongoDB selector. Used for matching on embedded associations.
    #
    # @example Does the document match?
    #   document.matches?(:title => { "$in" => [ "test" ] })
    #
    # @param [ Hash ] selector The MongoDB selector.
    #
    # @return [ true, false ] True if matches, false if not.
    def matches?(selector)
      selector.each_pair do |key, value|
        unless Strategies.matcher(self, key, value).matches?(value)
          return false
        end
      end
      return true
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

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