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.3.4 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.3.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.3.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.3.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.3.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classiccms-0.2.4.pre vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
mongoid-2.4.8 lib/mongoid/matchers/in.rb
classicCMS-0.2.3 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classicCMS-0.2.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classicCMS-0.2.1 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classicCMS-0.2.0 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
classicCMS-0.1.2 vendor/bundle/gems/mongoid-2.4.7/lib/mongoid/matchers/in.rb
mongoid-2.4.7 lib/mongoid/matchers/in.rb
mongoid-2.4.6 lib/mongoid/matchers/in.rb
mongoid-2.4.5 lib/mongoid/matchers/in.rb
mongoid-2.4.4 lib/mongoid/matchers/in.rb
mongoid-2.4.3 lib/mongoid/matchers/in.rb