Class: Attached::Job

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

Class Method Summary collapse

Class Method Details

.enqueue(attachment) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/attached/job.rb', line 16

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

  self.perform(klass, id, method)
end

.perform(klass, id, method) ⇒ Object



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

def self.perform(klass, id, method)
  object = klass.constantize.find(id)

  attachment = object.send(name)
  attachment.reprocess!
  attachment.status = 'active'

  object.save
end