123456789_123456789_123456789_123456789_123456789_

Module: Mongoid::Matcher::BitsAnySet Private

Do not use. This module is for internal use only.
Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Instance Chain:
self, Bits
Defined in: lib/mongoid/matcher/bits_any_set.rb

Overview

In-memory matcher for $bitsAnySet expression.

Instance Method Summary

Bits - Included

#matches?

Returns whether a value satisfies a bitwise expression.

Instance Method Details

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

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.

[ GitHub ]

  
# File 'lib/mongoid/matcher/bits_any_set.rb', line 22

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

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

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.

[ GitHub ]

  
# File 'lib/mongoid/matcher/bits_any_set.rb', line 36

def int_matches?(value, condition)
  value & condition > 0
end