Class: Mongoid::Matchable::And

Inherits:
Default
  • Object
show all
Defined in:
build/mongoid-7.0/lib/mongoid/matchable/and.rb

Overview

Defines behavior for handling $and expressions in embedded documents.

Since:

  • 4.0.0

Instance Attribute Summary

Attributes inherited from Default

#attribute, #document

Instance Method Summary collapse

Methods inherited from Default

#initialize

Constructor Details

This class inherits a constructor from Mongoid::Matchable::Default

Instance Method Details

#_matches?(conditions) ⇒ true, false

Does the supplied query match the attribute?

Examples:

Does this match?

matcher._matches?([ { field => value } ])

Parameters:

  • conditions (Array)

    The or expression.

Returns:

  • (true, false)

    True if matches, false if not.

Since:

  • 2.3.0



18
19
20
21
22
23
24
25
26
27
# File 'build/mongoid-7.0/lib/mongoid/matchable/and.rb', line 18

def _matches?(conditions)
  conditions.each do |condition|
    condition.keys.each do |k|
      key = k
      value = condition[k]
      return false unless document._matches?(key => value)
    end
  end
  true
end