Module: Mongoid::Matcher::BitsAllSet Private

Extended by:
BitsAllSet
Includes:
Bits
Included in:
BitsAllSet
Defined in:
lib/mongoid/matcher/bits_all_set.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

In-memory matcher for $bitsAllSet expression.

Instance Method Summary collapse

Methods included from Bits

#matches?, operator_name

Instance Method Details

#array_matches?(value, condition) ⇒ true | false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether a position list condition matches a value.

Parameters:

  • value (Object)

    The value to check.

  • condition (Array<Numeric>)

    The position list condition.

Returns:

  • (true | false)

    Whether the value matches.



22
23
24
25
26
# File 'lib/mongoid/matcher/bits_all_set.rb', line 22

def array_matches?(value, condition)
  condition.all? do |c|
    value & (1<<c) > 0
  end
end

#int_matches?(value, condition) ⇒ true | false

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns whether a bitmask condition matches a value.

Parameters:

  • value (Object)

    The value to check.

  • condition (Numeric)

    The bitmask condition.

Returns:

  • (true | false)

    Whether the value matches.



36
37
38
# File 'lib/mongoid/matcher/bits_all_set.rb', line 36

def int_matches?(value, condition)
  value & condition == condition
end