123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Matchable

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ActiveSupport::Concern
Defined in: lib/mongoid/matchable.rb

Overview

This module contains all the behavior for Ruby implementations of MongoDB selectors.

Instance Method Summary

Instance Method Details

#_matches?(selector) ⇒ true | false

Determines if this document has the attributes to match the supplied MongoDB selector. Used for matching on embedded associations.

Examples:

Does the document match?

document._matches?(:title => { "$in" => [ "test" ] })

Parameters:

  • selector (Hash) —

    The MongoDB selector.

Returns:

  • (true | false) —

    True if matches, false if not.

[ GitHub ]

  
# File 'lib/mongoid/matchable.rb', line 18

def _matches?(selector)
  # Opens a regexp budget for this document only. Callers that match many
  # documents against one selector open a budget of their own first, and
  # this one joins it rather than giving every document a fresh limit.
  Matcher::RegexpBudget.open(selector) do
    Matcher::Expression.matches?(self, selector)
  end
end