Sha256: 1b1d7dcd5a62eb371471b83bf08c20307c72dab2bcacb42b73e34b93e7c45970
Contents?: true
Size: 1.94 KB
Versions: 9
Compression:
Stored size: 1.94 KB
Contents
# encoding: utf-8 module Mongoid module Contextual class None include Enumerable include Queryable attr_reader :criteria, :klass # Check if the context is equal to the other object. # # @example Check equality. # context == [] # # @param [ Array ] other The other array. # # @return [ true, false ] If the objects are equal. # # @since 4.0.0 def ==(other) other.is_a?(None) end # Iterate over the null context. There are no documents to iterate over # in this case. # # @example Iterate over the context. # context.each do |doc| # puts doc.name # end # # @return [ Enumerator ] The enumerator. # # @since 4.0.0 def each if block_given? [].each { |doc| yield(doc) } self else to_enum end end # Do any documents exist for the context. # # @example Do any documents exist for the context. # context.exists? # # @return [ true, false ] If the count is more than zero. # # @since 4.0.0 def exists?; false; end # Create the new null context. # # @example Create the new context. # Null.new(criteria) # # @param [ Criteria ] The criteria. # # @since 4.0.0 def initialize(criteria) @criteria, @klass = criteria, criteria.klass end # Always returns nil. # # @example Get the last document. # context.last # # @return [ nil ] Always nil. # # @since 4.0.0 def last; nil; end # Always returns zero. # # @example Get the length of matching documents. # context.length # # @return [ Integer ] Always zero. # # @since 4.0.0 def length entries.length end alias :size :length end end end
Version data entries
9 entries across 9 versions & 2 rubygems