Sha256: 5e8e613d7d23b3bf68e535a86c39082d60e5097a6e71f75ff20359de980acb2d

Contents?: true

Size: 727 Bytes

Versions: 57

Compression:

Stored size: 727 Bytes

Contents

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

    # 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| 
          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

57 entries across 57 versions & 3 rubygems

Version Path
classiccms-0.7.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.7.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.7.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.7.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.7.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.7.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.9 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.8 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.7 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.6 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.5 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.6.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.5.17 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.5.16 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.5.15 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.5.14 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb