Module: Operationable::Persisters::Memory
- Included in:
- OperationJob
- Defined in:
- lib/operationable/persisters/memory.rb
Instance Method Summary collapse
-
#at(num, total, *messages) ⇒ Object
set the status of the job for the current itteration.
- #create_status_hash ⇒ Object
-
#should_kill? ⇒ Boolean
Checks against the kill list if this specific job instance should be killed on the next iteration.
-
#status ⇒ Object
get the Resque::Plugins::Status::Hash object for the current uuid.
-
#status=(new_status) ⇒ Object
Set the jobs status.
-
#tick(*messages) ⇒ Object
sets the status of the job for the current itteration.
Instance Method Details
#at(num, total, *messages) ⇒ Object
set the status of the job for the current itteration. num and total are passed to the status as well as any messages. This will kill the job if it has been added to the kill list with Resque::Plugins::Status::Hash.kill()
33 34 35 36 37 38 39 40 41 |
# File 'lib/operationable/persisters/memory.rb', line 33 def at(num, total, *) if total.to_f <= 0.0 raise(NotANumber, "Called at() with total=#{total} which is not a number") end tick({ 'num' => num, 'total' => total }, *) end |
#create_status_hash ⇒ Object
8 9 10 |
# File 'lib/operationable/persisters/memory.rb', line 8 def create_status_hash Resque::Plugins::Status::Hash.create(uuid, ) end |
#should_kill? ⇒ Boolean
Checks against the kill list if this specific job instance should be killed on the next iteration
25 26 27 |
# File 'lib/operationable/persisters/memory.rb', line 25 def should_kill? Resque::Plugins::Status::Hash.should_kill?(uuid) end |
#status ⇒ Object
get the Resque::Plugins::Status::Hash object for the current uuid
19 20 21 |
# File 'lib/operationable/persisters/memory.rb', line 19 def status Resque::Plugins::Status::Hash.get(uuid) end |
#status=(new_status) ⇒ Object
Set the jobs status. Can take an array of strings or hashes that are merged (in order) into a final status hash.
14 15 16 |
# File 'lib/operationable/persisters/memory.rb', line 14 def status=(new_status) Resque::Plugins::Status::Hash.set(uuid, *new_status) end |
#tick(*messages) ⇒ Object
sets the status of the job for the current itteration. You should use the at method if you have actual numbers to track the iteration count. This will kill the job if it has been added to the kill list with Resque::Plugins::Status::Hash.kill()
47 48 49 50 |
# File 'lib/operationable/persisters/memory.rb', line 47 def tick(*) kill! if should_kill? set_status({'status' => Operationable::Persisters::Base::STATUS_WORKING}, *) end |