Sha256: b781e2e0c9bdc3754a256edf99686a7c982f802d90f5cbe36df0acc4cb1f3d9f

Contents?: true

Size: 693 Bytes

Versions: 32

Compression:

Stored size: 693 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchers

    # Checks that all values match.
    class All < Default

      # Return true if the attribute and first value in the hash are equal.
      #
      # @example Do the values match?
      #   matcher.matches?({ :key => 10 })
      #
      # @param [ Hash ] value The values to check.
      #
      # @return [ true, false ] If the values match.
      def matches?(value)
        first = first(value)
        return false if first.is_a?(Array) && first.empty?

        attribute_array = Array.wrap(@attribute)
        first.all? do |e|
          attribute_array.any? { |_attribute| e === _attribute }
        end
      end
    end
  end
end

Version data entries

32 entries across 32 versions & 2 rubygems

Version Path
mongoid-3.0.12 lib/mongoid/matchers/all.rb
mongoid-3.0.11 lib/mongoid/matchers/all.rb
mongoid-3.0.10 lib/mongoid/matchers/all.rb
mongoid-3.0.9 lib/mongoid/matchers/all.rb
mongoid-3.0.6 lib/mongoid/matchers/all.rb
mongoid-3.0.5 lib/mongoid/matchers/all.rb
mongoid-3.0.4 lib/mongoid/matchers/all.rb
mongoid-3.0.3 lib/mongoid/matchers/all.rb
mongoid-3.0.2 lib/mongoid/matchers/all.rb
mongoid-3.0.1 lib/mongoid/matchers/all.rb
mongoid-3.0.0 lib/mongoid/matchers/all.rb
mongoid-3.0.0.rc lib/mongoid/matchers/all.rb