module DeleteRecursively::DependencyHandling

override Association#handle_dependency to apply the new option if it is set

Public Instance Methods

delete_dependencies_recursively(force: false) click to toggle source
# File lib/delete_recursively/active_record_extensions.rb, line 19
def delete_dependencies_recursively(force: false)
  if reflection.belongs_to?
    # Special case. The owner is already destroyed at this point,
    # so we cannot use the efficient ::dependent_ids lookup. Note that this
    # only happens for a single entry-record on #destroy, though.
    return unless target = load_target

    DeleteRecursively.delete_records_recursively(target.class, target.id, force: force)
  else
    DeleteRecursively.delete_recursively(reflection, nil, owner.id, force: force)
  end
end
handle_dependency() click to toggle source
Calls superclass method
# File lib/delete_recursively/active_record_extensions.rb, line 11
def handle_dependency
  if DeleteRecursively.enabled_for?(self)
    delete_dependencies_recursively
  else
    super
  end
end