summaryrefslogtreecommitdiff
path: root/app/workers/reactive_caching_worker.rb
blob: 9ec8bcca4f3a78a40fbd41156506995d54ce357a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

class ReactiveCachingWorker
  include ApplicationWorker

  # rubocop: disable CodeReuse/ActiveRecord
  def perform(class_name, id, *args)
    klass = begin
      class_name.constantize
    rescue NameError
      nil
    end
    return unless klass

    klass.find_by(klass.primary_key => id).try(:exclusively_update_reactive_cache!, *args)
  end
  # rubocop: enable CodeReuse/ActiveRecord
end