lib/mongoid/traversable.rb
# Collect all the descendants of this document.
#
# @return [ Array<Document> ] The descendants.
#
# @api private
Collect all the descendants of this document.
Collect all the descendants of this document .
def collect_descendants
      children = []
      to_expand = []
      expanded = {}
      embedded_relations.each_pair do |name, association|
        without_autobuild do
          child = send(name)
          if child
            to_expand += Array.wrap(child)
          end
        end
      end
      until to_expand.empty?
        expanding = to_expand
        to_expand = []
        expanding.each do |child|
          next if expanded[child]
          expanded[child] = true
          children << child
          to_expand += child._children
        end
      end
      children
    end
def collect_descendants children = [ ] to_expand = [ ] expanded = { } embedded_relations . each_pair do | name , association | without_autobuild do child = send ( name ) if child to_expand += Array . wrap ( child ) end end end until to_expand . empty? expanding = to_expand to_expand = [ ] expanding . each do | child | next if expanded [ child ] expanded [ child ] = true children << child to_expand += child . _children end end children end
Collect all the descendants of this document.
Collect all the descendants of this document .
None
 Array<Document> 
api
None