class Mongoid::Contextual::None

def ==(other)

Returns:
  • (true | false) - If the objects are equal.

Parameters:
  • other (Array) -- The other array.

Other tags:
    Example: Check equality. -
def ==(other)
  other.is_a?(None)
end

def distinct(_field)

Returns:
  • (Array) - An empty Array.

Parameters:
  • _field (String | Symbol) -- The name of the field.

Other tags:
    Example: Get the distinct values in null context. -
def distinct(_field)
  []
end

def each

Returns:
  • (Enumerator) - The enumerator.

Other tags:
    Example: Iterate over the null context. -
def each
  if block_given?
    [].each { |doc| yield(doc) }
    self
  else
    to_enum
  end
end

def exists?(id_or_conditions = :none); false; end

Returns:
  • (false) - Always false.

Parameters:
  • id_or_conditions (Hash | Object | false) -- an _id to

Other tags:
    Example: Do any documents exist for given conditions. -
    Example: Do any documents exist for given _id. -
    Example: Do any documents exist in the null context. -
def exists?(id_or_conditions = :none); false; end

def fifth

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the fifth document in null context. -
def fifth
  nil
end

def fifth!

Other tags:
    Example: Get the fifth document in null context. -
def fifth!
  raise_document_not_found_error
end

def first(limit = nil)

Returns:
  • ([] | nil) - Empty array or nil.

Parameters:
  • limit (Integer) -- The number of documents to return.

Other tags:
    Example: Get the first document in null context. -
def first(limit = nil)
  [] unless limit.nil?
end

def first!

Other tags:
    Example: Get the first document in null context. -
def first!
  raise_document_not_found_error
end

def fourth

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the fourth document in null context. -
def fourth
  nil
end

def fourth!

Other tags:
    Example: Get the fourth document in null context. -
def fourth!
  raise_document_not_found_error
end

def initialize(criteria)

Parameters:
  • criteria (Criteria) -- The criteria.

Other tags:
    Example: Create the new context. -
def initialize(criteria)
  @criteria, @klass = criteria, criteria.klass
end

def last(limit = nil)

Returns:
  • ([] | nil) - Empty array or nil.

Parameters:
  • limit (Integer) -- The number of documents to return.

Other tags:
    Example: Get the last document in null context. -
def last(limit = nil)
  [] unless limit.nil?
end

def last!

Other tags:
    Example: Get the last document in null context. -
def last!
  raise_document_not_found_error
end

def length

Returns:
  • (Integer) - Always zero.

Other tags:
    Example: Get the length of null context. -
def length
  Mongoid.broken_aggregables ? 0 : entries.length
end

def pick(*_fields)

Returns:
  • (nil) - Always return nil.

Parameters:
  • *_fields ([ String | Symbol ]...) -- Field(s) to pick.

Other tags:
    Example: Get the value for null context. -
def pick(*_fields)
  nil
end

def pluck(*_fields)

Returns:
  • (Array) - An empty Array.

Parameters:
  • *_fields ([ String | Symbol ]...) -- Field(s) to pluck.

Other tags:
    Example: Get the values for null context. -
def pluck(*_fields)
  []
end

def raise_document_not_found_error

def raise_document_not_found_error
  raise Errors::DocumentNotFound.new(klass, nil, nil)
end

def second

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the second document in null context. -
def second
  nil
end

def second!

Other tags:
    Example: Get the second document in null context. -
def second!
  raise_document_not_found_error
end

def second_to_last

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the second to last document in null context. -
def second_to_last
  nil
end

def second_to_last!

Other tags:
    Example: Get the second to last document in null context. -
def second_to_last!
  raise_document_not_found_error
end

def sum(_field = nil)

Returns:
  • (Integer | Symbol) - If Mongoid.broken_aggregables is

Parameters:
  • _field (Symbol) -- The field to sum.

Other tags:
    Example: Get the sum of null context. -
def sum(_field = nil)
  if Mongoid.broken_aggregables
    old_sum(_field)
  else
    new_sum(_field)
  end
end

def take(limit = nil)

Returns:
  • ([] | nil) - Empty array or nil.

Parameters:
  • limit (Integer | nil) -- The number of documents to take or nil.

Other tags:
    Example: Take a document in null context. -
def take(limit = nil)
  limit ? [] : nil
end

def take!

Other tags:
    Example: Take a document in null context. -
def take!
  raise_document_not_found_error
end

def tally(_field)

Returns:
  • (Hash) - An empty Hash.

Parameters:
  • _field (String | Symbol) -- Field to tally.

Other tags:
    Example: Get the values for null context. -
def tally(_field)
  {}
end

def third

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the third document in null context. -
def third
  nil
end

def third!

Other tags:
    Example: Get the third document in null context. -
def third!
  raise_document_not_found_error
end

def third_to_last

Returns:
  • (nil) - Always nil.

Other tags:
    Example: Get the third to last document in null context. -
def third_to_last
  nil
end

def third_to_last!

Other tags:
    Example: Get the third to last document in null context. -
def third_to_last!
  raise_document_not_found_error
end