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.



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

def initialize attributes = {}
  @id         = attributes[:id]
  @created_at = attributes[:created_at]
  @run_at     = attributes[:run_at]
  @queue      = attributes[:queue]
  @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.



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

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.



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

def failed_at
  @failed_at
end

#handlerObject

Returns the value of attribute handler.



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

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.



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

def last_error
  @last_error
end

#locked_atObject

Returns the value of attribute locked_at.



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

def locked_at
  @locked_at
end

#locked_byObject

Returns the value of attribute locked_by.



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

def locked_by
  @locked_by
end

#queueObject

Returns the value of attribute queue.



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

def queue
  @queue
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



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

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

.build_executingObject



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

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



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

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



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

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



50
51
52
# File 'app/models/delayed/web/job/double.rb', line 50

def self.decorate job
  StatusDecorator.new job
end

.find(*args) ⇒ Object



40
41
42
# File 'app/models/delayed/web/job/double.rb', line 40

def self.find *args
  decorate build_failed
end

Instance Method Details

#destroyObject



36
37
38
# File 'app/models/delayed/web/job/double.rb', line 36

def destroy
  self
end

#queue!Object



32
33
34
# File 'app/models/delayed/web/job/double.rb', line 32

def queue!
  true
end

#to_paramObject



28
29
30
# File 'app/models/delayed/web/job/double.rb', line 28

def to_param
  id
end