Class: Delayed::Web::Job::Double

Inherits:
Object
  • Object
show all
Defined in:
app/models/delayed/web/job/double.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Double

Returns a new instance of Double.



14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/delayed/web/job/double.rb', line 14

def initialize attributes = {}
  @id         = attributes[:id]
  @created_at = attributes[:created_at]
  @run_at     = attributes[:run_at]
  @attempts   = attributes[:attempts]
  @failed_at  = attributes[:failed_at]
  @locked_at  = attributes[:locked_at]
  @locked_by  = attributes[:locked_by]
  @last_error = attributes[:last_error]
  @handler    = attributes[:handler]
end

Instance Attribute Details

#attemptsObject

Returns the value of attribute attempts.



7
8
9
# File 'app/models/delayed/web/job/double.rb', line 7

def attempts
  @attempts
end

#created_atObject

Returns the value of attribute created_at.



5
6
7
# File 'app/models/delayed/web/job/double.rb', line 5

def created_at
  @created_at
end

#failed_atObject

Returns the value of attribute failed_at.



8
9
10
# File 'app/models/delayed/web/job/double.rb', line 8

def failed_at
  @failed_at
end

#handlerObject

Returns the value of attribute handler.



12
13
14
# File 'app/models/delayed/web/job/double.rb', line 12

def handler
  @handler
end

#idObject

Returns the value of attribute id.



4
5
6
# File 'app/models/delayed/web/job/double.rb', line 4

def id
  @id
end

#last_errorObject

Returns the value of attribute last_error.



11
12
13
# File 'app/models/delayed/web/job/double.rb', line 11

def last_error
  @last_error
end

#locked_atObject

Returns the value of attribute locked_at.



9
10
11
# File 'app/models/delayed/web/job/double.rb', line 9

def locked_at
  @locked_at
end

#locked_byObject

Returns the value of attribute locked_by.



10
11
12
# File 'app/models/delayed/web/job/double.rb', line 10

def locked_by
  @locked_by
end

#run_atObject

Returns the value of attribute run_at.



6
7
8
# File 'app/models/delayed/web/job/double.rb', line 6

def run_at
  @run_at
end

Class Method Details

.allObject



42
43
44
45
46
# File 'app/models/delayed/web/job/double.rb', line 42

def self.all
  [build_executing, build_failed, build_queued].map do |job|
    decorate job
  end
end

.build_executingObject



52
53
54
55
56
# File 'app/models/delayed/web/job/double.rb', line 52

def self.build_executing
  new id: 1, created_at: 1.minute.ago, run_at: 1.minute.ago,
    attempts: 1, last_error: nil, locked_at: 30.seconds.ago,
    locked_by: 'host.local', handler: '---'
end

.build_failedObject



58
59
60
61
62
# File 'app/models/delayed/web/job/double.rb', line 58

def self.build_failed
  new id: 2, created_at: 5.hours.ago, run_at: 2.hours.from_now,
    attempts: 4, failed_at: 1.hour.ago, last_error: 'RuntimeError: RuntimeError',
    locked_at: nil, locked_by: nil, handler: '---'
end

.build_queuedObject



64
65
66
67
68
# File 'app/models/delayed/web/job/double.rb', line 64

def self.build_queued
  new id: 3, created_at: 30.seconds.ago, run_at: 30.seconds.ago,
    attempts: 0, last_error: nil, locked_at: nil, locked_by: nil,
    handler: '---'
end

.decorate(job) ⇒ Object



48
49
50
# File 'app/models/delayed/web/job/double.rb', line 48

def self.decorate job
  StatusDecorator.new job
end

.find(*args) ⇒ Object



38
39
40
# File 'app/models/delayed/web/job/double.rb', line 38

def self.find *args
  decorate build_failed
end

Instance Method Details

#destroyObject



34
35
36
# File 'app/models/delayed/web/job/double.rb', line 34

def destroy
  self
end

#queue!Object



30
31
32
# File 'app/models/delayed/web/job/double.rb', line 30

def queue!
  true
end

#to_paramObject



26
27
28
# File 'app/models/delayed/web/job/double.rb', line 26

def to_param
  id
end