Sha256: 28698600d426bc5e13b695b62dc02a51e325602fa8849f89d7845ae76cbfe1d6

Contents?: true

Size: 609 Bytes

Versions: 4

Compression:

Stored size: 609 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 = Array.wrap(@attribute)
        value.values.first.any? do |e|
          attribute_array.any? { |_attribute| e === _attribute }
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 3 rubygems

Version Path
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/matchable/in.rb
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/matchable/in.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/matchable/in.rb
mongoid_rails4-4.0.0 lib/mongoid/matchable/in.rb