Class: DelayedCrud::Job::SidekiqJob::DelayedCrudJob

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
lib/delayed_crud/job/sidekiq_job.rb

Overview

:nodoc:

Instance Method Summary collapse

Instance Method Details

#perform(class_name, record_id, operation, attributes = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/delayed_crud/job/sidekiq_job.rb', line 13

def perform(class_name, record_id, operation, attributes = {})
  record = record_id ? class_name.constantize.find(record_id) : class_name.constantize

  case operation.to_sym
  when :create, :update
    record.send(operation, attributes)
  when :destroy
    record.send(operation)
  else
    raise ArgumentError, "Unsupported operation: #{operation}"
  end
end