Skip to content

Instantly share code, notes, and snippets.

@brunomichetti
Created August 27, 2019 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunomichetti/ea6c41e5473d9e808e5c7f7bf59a4d41 to your computer and use it in GitHub Desktop.
Save brunomichetti/ea6c41e5473d9e808e5c7f7bf59a4d41 to your computer and use it in GitHub Desktop.
class CCRecalculationEnqueuer < CCEnqueuer
def perform
class_to_update = @options[:relation_class_name].constantize
instance_id = @options[:relation_id]
instance = class_to_update.public_send(:find, instance_id)
method_name = @options[:method]
instance.public_send(method_name.to_sym)
unmark_as_queued
end
private
def enqueuer_name
'recalculation'
end
def form_key
class_name = @options[:relation_class_name]
column_name = @options[:column]
instance_id = @options[:relation_id]
"cc::#{class_name}::#{instance_id}::#{column_name}::recalculation"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment