Class: HasAttachable::Worker

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Status::Worker, Sidekiq::Worker
Defined in:
lib/has_attachable/worker.rb

Instance Method Summary collapse

Instance Method Details

#perform(method, options) ⇒ Object



11
12
13
# File 'lib/has_attachable/worker.rb', line 11

def perform(method, options)
  send("#{method}", Hash[options.map{ |k, v| [k.to_sym, v] }])
end

#process(options) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/has_attachable/worker.rb', line 15

def process(options)
  object = options[:klass].classify.constantize.unscoped.where(id: options[:id]).first
  object.send(options[:context]).cache_stored_file! 
  object.send(options[:context]).retrieve_from_cache!(object.send(options[:context]).cache_name)
  object.send(options[:context]).recreate_versions!
  object.untrack_job_id(options[:context])
end

#remove(options) ⇒ Object



23
24
25
26
27
# File 'lib/has_attachable/worker.rb', line 23

def remove(options)
  object = options[:klass].classify.constantize.unscoped.where(id: options[:id]).first
  object.send("remove_#{options[:context]}!")
  object.untrack_job_id(options[:context])
end