Sha256: 15742b7bff0f535e28898111fc693eee30e6e69ca04234f837f1d479e4e60ef6

Contents?: true

Size: 637 Bytes

Versions: 27

Compression:

Stored size: 637 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

    # Performs matching for any value in an array.
    class In < Default

      # Return true if the attribute is in the values.
      #
      # @example Do the values match?
      #   matcher._matches?({ :key => 10 })
      #
      # @param [ Hash ] value The values to check.
      #
      # @return [ true, false ] If a value exists.
      def _matches?(value)
        attribute_array = @attribute.nil? ? [nil] : Array.wrap(@attribute)
        value.values.first.any? do |e|
          attribute_array.any? { |_attribute| e === _attribute }
        end
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/matchable/in.rb
mongoid-7.0.12 lib/mongoid/matchable/in.rb
mongoid-6.4.8 lib/mongoid/matchable/in.rb
mongoid-7.0.11 lib/mongoid/matchable/in.rb
mongoid-7.0.10 lib/mongoid/matchable/in.rb
mongoid-6.4.7 lib/mongoid/matchable/in.rb
mongoid-6.4.5 lib/mongoid/matchable/in.rb
mongoid-7.0.8 lib/mongoid/matchable/in.rb
mongoid-7.0.7 lib/mongoid/matchable/in.rb
mongoid-7.0.6 lib/mongoid/matchable/in.rb
mongoid-7.0.5 lib/mongoid/matchable/in.rb
mongoid-7.0.4 lib/mongoid/matchable/in.rb
mongoid-6.4.4 lib/mongoid/matchable/in.rb
mongoid-7.0.3 lib/mongoid/matchable/in.rb
mongoid-6.4.2 lib/mongoid/matchable/in.rb
mongoid-7.0.2 lib/mongoid/matchable/in.rb
mongoid-7.0.1 lib/mongoid/matchable/in.rb
mongoid-6.4.1 lib/mongoid/matchable/in.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/matchable/in.rb
mongoid-7.0.0 lib/mongoid/matchable/in.rb