Sha256: 3211f2bc9956608b9f660c3f9c779de7a14e54b7b9b4d1378496e17586326b96

Contents?: true

Size: 584 Bytes

Versions: 27

Compression:

Stored size: 584 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

    # Checks for existence.
    class Exists < Default

      # Return true if the attribute exists and checking for existence or
      # return true if the attribute does not exist and checking for
      # non-existence.
      #
      # @example Does anything exist?
      #   matcher._matches?({ :key => 10 })
      #
      # @param [ Hash ] value The values to check.
      #
      # @return [ true, false ] If a value exists.
      def _matches?(value)
        @attribute.nil? != value.values.first
      end
    end
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mongoid-7.0.13 lib/mongoid/matchable/exists.rb
mongoid-7.0.12 lib/mongoid/matchable/exists.rb
mongoid-6.4.8 lib/mongoid/matchable/exists.rb
mongoid-7.0.11 lib/mongoid/matchable/exists.rb
mongoid-7.0.10 lib/mongoid/matchable/exists.rb
mongoid-6.4.7 lib/mongoid/matchable/exists.rb
mongoid-6.4.5 lib/mongoid/matchable/exists.rb
mongoid-7.0.8 lib/mongoid/matchable/exists.rb
mongoid-7.0.7 lib/mongoid/matchable/exists.rb
mongoid-7.0.6 lib/mongoid/matchable/exists.rb
mongoid-7.0.5 lib/mongoid/matchable/exists.rb
mongoid-7.0.4 lib/mongoid/matchable/exists.rb
mongoid-6.4.4 lib/mongoid/matchable/exists.rb
mongoid-7.0.3 lib/mongoid/matchable/exists.rb
mongoid-6.4.2 lib/mongoid/matchable/exists.rb
mongoid-7.0.2 lib/mongoid/matchable/exists.rb
mongoid-7.0.1 lib/mongoid/matchable/exists.rb
mongoid-6.4.1 lib/mongoid/matchable/exists.rb
tdiary-5.0.8 vendor/bundle/gems/mongoid-6.4.0/lib/mongoid/matchable/exists.rb
mongoid-7.0.0 lib/mongoid/matchable/exists.rb