rename delete_all_records to delete_or_nullify_all_records
Rename delete_all_records because this name better describes what the method is doing. We can then remove :all from the hm:t version and pull out the unoptimized call to load_target in delete_records and pass it directly.
This commit is contained in:
parent
1c851b8cdf
commit
05a90c36c5
@ -194,7 +194,7 @@ def delete_all(dependent = nil)
|
||||
options[:dependent]
|
||||
end
|
||||
|
||||
delete_all_records(dependent).tap do
|
||||
delete_or_nullify_all_records(dependent).tap do
|
||||
reset
|
||||
loaded!
|
||||
end
|
||||
|
@ -113,7 +113,7 @@ def delete_count(method, scope)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_all_records(method)
|
||||
def delete_or_nullify_all_records(method)
|
||||
count = delete_count(method, self.scope)
|
||||
update_counter(-count)
|
||||
end
|
||||
|
@ -130,17 +130,13 @@ def update_through_counter?(method)
|
||||
end
|
||||
end
|
||||
|
||||
def delete_all_records(method)
|
||||
delete_records(:all, method)
|
||||
def delete_or_nullify_all_records(method)
|
||||
delete_records(load_target, method)
|
||||
end
|
||||
|
||||
def delete_records(records, method)
|
||||
ensure_not_nested
|
||||
|
||||
# This is unoptimised; it will load all the target records
|
||||
# even when we just want to delete everything.
|
||||
records = load_target if records == :all
|
||||
|
||||
scope = through_association.scope
|
||||
scope.where! construct_join_attributes(*records)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user