class Mongoid::PersistenceContext

def for_child(document)

Other tags:
    Api: - private

Returns:
  • (PersistenceContext) - the new persistence context

Parameters:
  • document (Mongoid::Document | Class) -- the child document
def for_child(document)
  if document.is_a?(Class)
    return self if document == (@object.is_a?(Class) ? @object : @object.class)
  elsif document.is_a?(Mongoid::Document)
    return self if document.class == (@object.is_a?(Class) ? @object : @object.class)
  else
    raise ArgumentError, 'must specify a class or a document instance'
  end
  PersistenceContext.new(document, options.merge(document.storage_options))
end