Class: Attached::Job

Inherits:
Object
  • Object
show all
Defined in:
lib/attached/job.rb

Class Method Summary collapse

Class Method Details

.enqueue(attachment) ⇒ Object



14
15
16
17
18
19
# File 'lib/attached/job.rb', line 14

def self.enqueue(attachment)
  klass = attachment.instance.class.name
  id = attachment.instance.id
  method = attachment.name
  attachment.status = 'processing'
end

.perform(klass, id, method) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/attached/job.rb', line 6

def self.perform(klass, id, method)
  object = eval(klass).find(id)
  attachment = object.send(name)
  attachment.reprocess!
  attachment.status = 'active'
  object.save
end