Class: Writefully::Workers::Journalist
Instance Attribute Summary
Attributes inherited from BaseWorker
#message
Instance Method Summary
collapse
Methods inherited from BaseWorker
#actor_died, #close_db_connection!, #perform
Instance Method Details
#message_with_tries ⇒ Object
20
21
22
|
# File 'lib/writefully/workers/journalist.rb', line 20
def message_with_tries
message.merge({ tries: (message[:tries] || 1) + 1, run: false })
end
|
#on_death(actor, reason) ⇒ Object
24
25
26
|
# File 'lib/writefully/workers/journalist.rb', line 24
def on_death actor, reason
Writefully.add_job :journalists, message_with_tries if message
end
|
#publish ⇒ Object
4
5
6
7
8
|
# File 'lib/writefully/workers/journalist.rb', line 4
def publish
Writefully.logger.info "Publishing #{message[:resource]} #{message[:slug]}"
pencil = Tools::Pencil.new_link(message)
pencil.perform
end
|
#remove ⇒ Object
10
11
12
13
14
15
16
17
18
|
# File 'lib/writefully/workers/journalist.rb', line 10
def remove
eraser = Tools::Eraser.new_link(message)
unless eraser.directory_exists?
Writefully.logger.info "Removing #{message[:resource]} #{message[:slug]}"
eraser.perform
else
eraser.terminate
end
end
|