Module: Jobit::Jobs::Commands

Included in:
Jobit::Jobby
Defined in:
lib/jobit/jobs/commands.rb

Instance Method Summary collapse

Instance Method Details

#add_message(text, force = false) ⇒ Object



42
43
44
45
46
47
# File 'lib/jobit/jobs/commands.rb', line 42

def add_message(text, force = false)
  if self.keep? || force
    self.message += text
    update
  end
end

#increase_triesObject



32
33
34
35
# File 'lib/jobit/jobs/commands.rb', line 32

def increase_tries
  self.tries += 1
  update
end

#lock!(worker_name) ⇒ Object



55
56
57
58
59
# File 'lib/jobit/jobs/commands.rb', line 55

def lock!(worker_name)
  self.locked_at= Time.now.to_f
  self.locked_by= worker_name
  update
end

#set_error(text) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/jobit/jobs/commands.rb', line 19

def set_error(text)
  self.error = text
  self.status = 'failed'
  self.stopped_at = Time.now.to_f
  self.failed_at = stopped_at
  update
end

#set_progress(num) ⇒ Object



37
38
39
40
# File 'lib/jobit/jobs/commands.rb', line 37

def set_progress(num)
  self.progress = num
  update
end

#set_start_timeObject



4
5
6
7
# File 'lib/jobit/jobs/commands.rb', line 4

def set_start_time
  self.started_at = Time.now.to_f
  update
end

#set_status(new_status) ⇒ Object



14
15
16
17
# File 'lib/jobit/jobs/commands.rb', line 14

def set_status(new_status)
  self.status = new_status
  update
end

#set_stop_timeObject



9
10
11
12
# File 'lib/jobit/jobs/commands.rb', line 9

def set_stop_time
  self.stopped_at = Time.now.to_f
  update
end

#set_tries(num) ⇒ Object



27
28
29
30
# File 'lib/jobit/jobs/commands.rb', line 27

def set_tries(num)
  self.tries = num
  update
end

#unlock!Object



49
50
51
52
53
# File 'lib/jobit/jobs/commands.rb', line 49

def unlock!
  self.locked_at= nil
  self.locked_by= nil
  update
end