Sha256: 3bbea2073a2da7b087b983648d7457de0cf2124ee7b3bedb07f34f491d4b490c

Contents?: true

Size: 734 Bytes

Versions: 104

Compression:

Stored size: 734 Bytes

Contents

# encoding: utf-8
module Mongoid #:nodoc:
  module Matchers #:nodoc:

    # 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)
        attribute_array = Array.wrap(@attribute)
        value.values.first.all? do |e|
          if e.is_a?(Regexp)
            attribute_array.any? { |_attribute| _attribute =~ e }
          else
            attribute_array.include?(e)
          end
        end
      end
    end
  end
end

Version data entries

104 entries across 58 versions & 2 rubygems

Version Path
classiccms-0.6.8 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.8 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.7 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.7 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
mongoid-2.5.1 lib/mongoid/matchers/all.rb
classiccms-0.6.6 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.6 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.5 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.5 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.4 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.4 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.3 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.3 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.2 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.2 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.1 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.1 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.6.0 vendor/bundle/gems/mongoid-2.4.10/lib/mongoid/matchers/all.rb
classiccms-0.6.0 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb
classiccms-0.5.17 vendor/bundle/gems/mongoid-2.4.9/lib/mongoid/matchers/all.rb