Skip to content
Snippets Groups Projects
Commit 4ded0411 authored by Jan Provaznik's avatar Jan Provaznik
Browse files

Allow pass additional options to use_fast_destroy

These options are then used when setting before destroy callback.
parent 9ccf8d03
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -76,8 +76,8 @@ module FastDestroyAll
##
# This method is to be defined on models which have fast destroyable models as children,
# and let us avoid to use `dependent: :destroy` hook
def use_fast_destroy(relation)
before_destroy(prepend: true) do
def use_fast_destroy(relation, opts = {})
set_callback :destroy, :before, opts.merge(prepend: true) do
perform_fast_destroy(public_send(relation)) # rubocop:disable GitlabSecurity/PublicSend
end
end
Loading
Loading
Loading
Loading
@@ -31,13 +31,9 @@ module WithUploads
 
# TODO: when feature flag is removed, we can use just dependent: destroy
# option on :file_uploads
before_destroy :remove_file_uploads
before_destroy :remove_file_uploads, unless: :fast_destroy_enabled?
 
use_fast_destroy :file_uploads
end
def perform_fast_destroy(subject)
super if fast_destroy_enabled?
use_fast_destroy :file_uploads, if: :fast_destroy_enabled?
end
 
def retrieve_upload(_identifier, paths)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment