Sha256: e8338be191f97851b89a302835ece2160f93f134a67d18433db6b9db55bc52c8

Contents?: true

Size: 582 Bytes

Versions: 17

Compression:

Stored size: 582 Bytes

Contents

# encoding: utf-8
module Mongoid
  module Matchable

    # Checks for existance.
    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

17 entries across 17 versions & 5 rubygems

Version Path
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/mongoid-4.0.2/lib/mongoid/matchable/exists.rb
mongoid-5.0.0 lib/mongoid/matchable/exists.rb
mongoid-5.0.0.rc0 lib/mongoid/matchable/exists.rb
mongoid-5.0.0.beta lib/mongoid/matchable/exists.rb
mongoid-4.0.2 lib/mongoid/matchable/exists.rb
mongoid-4.0.1 lib/mongoid/matchable/exists.rb
mongoid-4.0.0 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.rc2 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.rc1 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.beta2 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.beta1 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.alpha2 lib/mongoid/matchable/exists.rb
mongoid-4.0.0.alpha1 lib/mongoid/matchable/exists.rb
sepastian-mongoid-rails4-4.0.1.alpha lib/mongoid/matchable/exists.rb
sepastian-mongoid-rails4-4.0.0.alpha lib/mongoid/matchable/exists.rb
mongoid_heroku_stable-4.0.0 lib/mongoid/matchable/exists.rb
mongoid_rails4-4.0.0 lib/mongoid/matchable/exists.rb