Sha256: 30f7944faa3eb741625d10849f97dbeeaa8aba54df18ccc48d36725540e28e0b

Contents?: true

Size: 622 Bytes

Versions: 6

Compression:

Stored size: 622 Bytes

Contents

module Mongoid
  module Hierarchy
    # Collect all the children of this document.
    #
    # @example Collect all the children.
    #   document.collect_children
    #
    # @return [ Array<Document> ] The children.
    #
    # @since 2.4.0
    def collect_children
      children = []
      embedded_relations.each_pair do |name, metadata|
        without_autobuild do
          child = send(name)
          Array.wrap(child).each do |doc|
            children.push(doc)
            children.concat(doc._children) unless metadata.versioned?
          end if child
        end
      end
      children
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mongoid-versioning-2.0.0 lib/mongoid/core_ext/hierarchy.rb
mongoid-versioning-1.2.0 lib/mongoid/core_ext/hierarchy.rb
mongoid-versioning-1.1.0 lib/mongoid/core_ext/hierarchy.rb
mongoid-versioning-1.0.0 lib/mongoid/core_ext/hierarchy.rb
mongoid-versioning-1.0.0.beta2 lib/mongoid/core_ext/hierarchy.rb
mongoid-versioning-1.0.0.beta1 lib/mongoid/core_ext/hierarchy.rb