Module: DeleteYouLater::Model

Defined in:
lib/delete_you_later/model.rb

Instance Method Summary collapse

Instance Method Details

#delete_dependents_later(assoc, scope: DeleteYouLater.configuration.scope, batch_size: DeleteYouLater.configuration.batch_size) ⇒ Object



3
4
5
6
7
8
9
10
11
# File 'lib/delete_you_later/model.rb', line 3

def delete_dependents_later(assoc, scope: DeleteYouLater.configuration.scope, batch_size: DeleteYouLater.configuration.batch_size)
  klass = self.name

  after_commit on: :destroy do
    if send(assoc).exists?
      DeleteLaterJob.perform_later klass, id, assoc, scope: scope, batch_size: batch_size
    end
  end
end

#destroy_dependents_later(assoc, scope: DeleteYouLater.configuration.scope, batch_size: DeleteYouLater.configuration.batch_size) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/delete_you_later/model.rb', line 13

def destroy_dependents_later(assoc, scope: DeleteYouLater.configuration.scope, batch_size: DeleteYouLater.configuration.batch_size)
  klass = self.name

  after_commit on: :destroy do
    if send(assoc).exists?
      DestroyLaterJob.perform_later klass, id, assoc, scope: scope, batch_size: batch_size
    end
  end
end